How do I create a global exception catcher in VSTO
-
Monday, July 23, 2012 4:38 PMIn WebForm/MVC applications you can use Application_Error to catch all unhandled/uncaught exceptions. What is the equivalent in VSTO?
- Moved by Cindy Meister MVPMVP, Moderator Tuesday, July 24, 2012 9:37 AM VSTO-specific (From:Word for Developers)
All Replies
-
Wednesday, July 25, 2012 4:36 AMModerator
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
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- Proposed As Answer by Leo_GaoModerator Monday, July 30, 2012 1:26 AM
- Marked As Answer by Leo_GaoModerator Thursday, August 02, 2012 1:10 AM
-
Friday, July 27, 2012 3:22 PMThat 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

