Answered How do I create a global exception catcher in VSTO

  • Monday, July 23, 2012 4:38 PM
     
     
    In WebForm/MVC applications you can use Application_Error to catch all unhandled/uncaught exceptions. What is the equivalent in VSTO?

All Replies

  • Wednesday, July 25, 2012 4:36 AM
    Moderator
     
     

    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

  • Wednesday, July 25, 2012 8:23 AM
     
     Answered

    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
  • Friday, July 27, 2012 3:22 PM
     
     
    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