How to Debug Outlook Crashes

Add-in Express™ Support Service
That's what is more important than anything else

How to Debug Outlook Crashes
 
ludwigvan


Guest


Some of the users at my customer are reporting that our Outlook plugin is making their Outlook crash. The problem is we cannot reproduce the issue at all, even though I have personally observed the error when connecting to the user's computer. It happens randomly and I haven't been able to debug or reproduce the error. We have the global exception handler within AddinExpress and we log exceptions, but for these crashes, we get no report or error handling (no logs) at all.

The user gets the "Outlook has stopped working" message box and we haven't been able to make any progress on the matter.

Do you have any pointers as to how one would debug such an issue?

We are on the brink of cancelling our product we have been developing for the last two years completely due to this issue.

Thank you for your help.
Posted 24 Dec, 2018 06:44:59 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello ludwigvan,

First off, you need to locate the issue: add more debug messages to your code so that you know where the crash occurs. There are many, many possible causes so locating the code line that crashes is the goal to pursue.

Actually, to crash Outlook when using .NET, you need to fulfill two conditions: 1) you need to get an exception in unmanaged code: whether this occurs because you manipulate unmanaged memory or other unmanaged resources or the exception originates from within Outlook, 2) you should leave the exception unhandled.

What do you mean by "the global exception handler"? The point is: you cannot create a global exception handler in a .NET based add-in. This is because the unmanaged code of Office doesn't know anything about your .NET handlers.

ADXAddinModule and ADXOlFromsManager provide OnError events that allow you to handle exception that occurs in *the events handlers that Add-in Express is aware of*. Say, if you put a button on a task pane and throw an exception in the Click event of that button, no Add-in Express event handler will get that exception.

If the crash occurs in Outlook 2013-2019 32bit, check the recommendations we posted at https://www.add-in-express.com/creating-addins-blog/2017/12/19/large-address-aware-outlook2016/.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Dec, 2018 07:33:22 Top
ludwigvan


Guest


Hi Andrei,

Thank you very much for your answer, I will look into those. Yes, I meant the OnError handler ADX puts. I wasn't aware it wasn't catching every .NET error. As you say, most probably my issue is some unmanaged code that one of my dependencies called in though.


1. Do you have any pointer as to which types of errors that handler catches? I didn't understand your example, why wouldn't ADX be aware of that click handler, given that it is put via ADX?

2. Do you have any pointers as to how to add a log for each line? Perhaps a tool like PostSharp could achieve that automatically.

3. Does Windows keep a log of these types of crashes somewhere, in EventLog for example?
Posted 24 Dec, 2018 07:43:29 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Ludwig,

1. Do you have any pointer as to which types of errors that handler catches? I didn't understand your example, why wouldn't ADX be aware of that click handler, given that it is put via ADX?


The OnError event will help you to catch all exceptions thrown in your handlers of the Add-in Express events such as AddinModule.AddinInitialize, ADXRibbonButton.OnClick, ADXOutlookAppEvents.ExplorerActivate and so on. But OnError cannot catch exceptions that are thrown in your code that is outside of the ADX event handlers, for example the System.Windows.Forms.Button.Click event in your own dialog form or the System.Windows.Forms.Timer.Tick event that occurs in the specified interval.

2. Do you have any pointers as to how to add a log for each line? Perhaps a tool like PostSharp could achieve that automatically.


You can use any approach that suits you better, from the simplest System.Diagnostics.Debug.WriteLine() method to special .NET components or tools.

3. Does Windows keep a log of these types of crashes somewhere, in EventLog for example?


Yes, Event Viewer shall contain information about Outlook crashes, please check the Application log.
Posted 26 Dec, 2018 04:30:04 Top