Outlook 2007 Add-in Exception Handling
I have an Outlook 2007 Add-in that I recently inherited and there is currently an issue in production where some users are getting their add-in disabled periodically and seemingly randomly. There are no logs from the Add-in and there are try/catch (and eat) blocks around every method/event call into the add-in code. I have done some googling and found that Outlook does this "soft-disable" of Add-ins if there are unhandled exceptions thrown up to Outlook.
From what I can tell there are no exceptions that are being thrown up from the add-in. What I would like to do is either 1) Create some kind of global exception handler in the addin to be 100% sure that all exceptions are caught. Or 2) Somehow listen for outlook "disabling" the add-in in the registry and having this listener remove the reg key that outlook is setting.
I have attempted to do #1 by the following:
AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
System.Windows.Forms.Application.ThreadExceptio开发者_StackOverflown += Application_ThreadException;
but neither has been successful.
I realize that System.Windows.Forms.Application.ThreadException does not necessarily apply to Outlook Add-ins, but I figured why not try it.
Also, I had read that Outlook starts up a separate AppDomain for Add-ins so I was hoping that the AppDomain.CurrentDomain would work for this. I wrote some code that throws exceptions intentionally to test and could not get an entry into either of these events, and Outlook continued to disable the Add-in.
Any help/insight would be greatly appreciated.
when an outlook Addin gets disabled , it changes the load behavior from 3 to 2. You can check this load behavior from the registry to identify whether a Addin is disabled or not.
精彩评论