AddinModule.CurrentInstance or OutlookApp null without addin shutting down?

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

AddinModule.CurrentInstance or OutlookApp null without addin shutting down?
 
mio




Posts: 55
Joined: 2009-03-05
Hi,

we are seeing a strange non-repro behavior in an Outlook addin built with Add-in Express in which either AddinModule.CurrentInstance or the HostApplication property of the AddinModule seems to become null at some point while Outlook is running.

We know this because we have code similar to the following:

_logger.Trace("Aquiring session...");
NameSpace session = AddinModule.CurrentInstance.OutlookApp.Session;
_logger.Trace("Aquiring drafts folder...");

The middle line of this code will occasionally throw a NullReferenceException, meaning either CurrentInstance or OutlookApp seems to be null.

We also have logging on shutdown (in the AddinBeginShutdown and AddinFinalize events) which does not get triggered when the error occurs, so the add-in does not seem to be shutting down.

Do you have any suggestion as to what may be causing this issue?
Greetings

Fabian
Posted 01 Mar, 2018 05:26:17 Top
Andrei Smolin


Add-in Express team


Posts: 14982
Joined: 2006-05-11
Hello Fabian,

Do you have any code that uses the Office.COMAddin object obtained via OutlookApp.COMAddins[{your add-in ProgId}]?

mio writes:
We also have logging on shutdown (in the AddinBeginShutdown and AddinFinalize events) which does not get triggered when the error occurs, so the add-in does not seem to be shutting down.


Intercept the Quit event. When Outlook shuts down, the events above don't work without registry modifications; by default they only work if you disable your add-in via the COM add-in dialog.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 01 Mar, 2018 06:10:28 Top
mio




Posts: 55
Joined: 2009-03-05
Hi Andrei,

I'm afraid we do not use OutlookApp.COMAddins anywhere in our code.

We are certain that Outlook is not actually shutting down when the condition occurs as it stays active and working after the error occurred - we just suspected that our add-in might get disconnected. Do you still think it will be helpful to intercept the Quit event? Are you aware of any conditions in which that event might be fired without Outlook itself shutting down?

Thanks
Greetings

Fabian
Posted 06 Mar, 2018 04:49:55 Top
Andrei Smolin


Add-in Express team


Posts: 14982
Joined: 2006-05-11
Hello Fabian,

Do you use threads in your code? Is it possible that the code producing the issue is run on a background thread?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Mar, 2018 07:34:46 Top