How do I create a global exception catcher in VSTO

Respondido How do I create a global exception catcher in VSTO

  • segunda-feira, 23 de julho de 2012 16:38
     
     
    In WebForm/MVC applications you can use Application_Error to catch all unhandled/uncaught exceptions. What is the equivalent in VSTO?

Todas as Respostas

  • quarta-feira, 25 de julho de 2012 04:36
    Moderador
     
     

    Hi,

    Thanks for posting in the MSDN Forum.

    As far as I know, the Application_Error handler is created in an Global.asax file which is disable in vsto project. So I would suggest you use the Try/Catch to catch exception for VSTO.

    Hope this can help you.

    Best Regards,


    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

  • quarta-feira, 25 de julho de 2012 08:23
     
     Respondido

    how global erros are handled in web application and VSTO which is a client technology is coimpletly different thing. You must take care of following things:

    1. in all VSTO raised events there should be try/catch clause to not let your exceptions escape - events like Addin Startup, Shutdown, and all others that you subscribe to using proper office API

    2. if you will use background threads you can also use

    System

    .Windows.Forms.Application.ThreadException and AppDomain.CurrentDomain.UnhandledException
    • Sugerido como Resposta Leo_GaoModerator segunda-feira, 30 de julho de 2012 01:26
    • Marcado como Resposta Leo_GaoModerator quinta-feira, 2 de agosto de 2012 01:10
    •  
  • sexta-feira, 27 de julho de 2012 15:22
     
     
    That is acceptable if that is the only option. If it is, it seems clanky and is not as elegant as the option is ASP.NET