Why is AddinBeginShutDown firing?

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

Why is AddinBeginShutDown firing?
Add-in disables itself for no apparent reason 
Mike VE




Posts: 168
Joined: 2007-09-09
I have a mature ADX solution that has just started to develop some weird behaviour while debugging in Visual Studio.
It disables itself when Outlook starts though Outlook does not crash. I can enable it and start it using Outlook's COM Add-ins box.

It hits all the break points correctly, including the ExplorerFolderSwitch sub, and the addin shows up on the ribbon.

If I close and restart it, or simply switch folders, the AddinBeginShutDown event fires.

I thought this must be to do with some utility code in a different solution that I had recently refactored and that was called by the ExplorerFolderSwitch event so I commented this out. However, the strange behaviour remains. I cannot get a handle on what is causing the AddinBeginShutDown to fire.

Any suggestions as to how I can debug it?
Posted 10 Aug, 2018 10:30:48 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Mike,

Below are two citation from https://www.add-in-express.com/creating-addins-blog/2010/05/04/outlook2010-fast-shutdown/:


You can enable shutdown notifications for your Outlook add-in by adding an additional value to the add-in registration key in the HKCU or HKLM registry hives:

Key: HKCU\Software\Microsoft\Office\Outlook\Add-ins\<YourAddinProgID>
Value: RequireShutdownNotification (DWORD)

Setting this value to 1 enables the add-in to receive both events during Outlook shutdown.



Outlook 2010 will call the AddinBeginShutdown and AddinFinalize events when the user disconnects your add-in by using the COM Add-ins dialog box.


Does any of these applies?


Andrei Smolin
Add-in Express Team Leader
Posted 13 Aug, 2018 05:27:24 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Is it possible that your add-in is installed and registered at the same time?


Andrei Smolin
Add-in Express Team Leader
Posted 13 Aug, 2018 05:28:10 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Thanks for the replies. I have checked it is not installed on my dev machine. I unregistered both in Debug and Release mode then re-registered in Debug only. The problem is still there.

The stack trace for the AddinBeginShutdown event shows
AddinExpress.MSO.2005.dll!AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IDTExtensibility2.OnDisconnection(AddinExpress.MSO.ext_DisconnectMode disconnectMode, ref System.Array custom) but no indication as to what triggered it.

The only recent work on the solution that I can think may be connected was some refactoring to old code which did not properly follow the one dot rule for referring to COM objects. That could mean I am releasing/disposing of objects that I should not. Could that be the cause?
Posted 14 Aug, 2018 04:47:57 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Mike,

Maybe you test this by starting the Outlook programmatically? Or, you send an email using Send To | Mail Recipient in the Windows Explorer or share the document from an Office application?

Check if there is any other add-in that turns this one off. In your code check if you use COMAddin or COMAddins objects and set COMAddin.Connect = false.

Comment out the add-in's functionality part by part to check if the issue is caused by your code.


Andrei Smolin
Add-in Express Team Leader
Posted 14 Aug, 2018 08:16:20 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Hi Andrei

Thanks for the pointers.

I tried starting Outlook as you suggested by sending a document in windows Explorer to the mail client, having previously ensured that the add-in was enabled. Once again the add-in was disabled and the items that should have been in the Inspector ribbon were not there.

I searched the whole solution to confirm that there is no COMAddin or COMAddins objects anywhere.

I commented out all the code in the ADX vb.net event handlers that occur in the startup sequence. If I then run the code Outlook shows with my add-in ribbon correctly loaded. If I then change folders the ADX AddinBeginShutdown events fires and the addin disappears. I tired again commenting out, in addition, the actual opening and closing lines including the Hanles statement. This suggests that my code in these events is not the problem.

I have just discovered what may be another clue. If, having re-enabled the addin and run it I click a menu button this calls an object that should have been set up in the AddinStartupCpmplete code, which is commented out and Outlook crashes. Now when I click the commend to show disabled COM addins both PrintJust1.AddinModule(adxloader) and printjust1.addinmodule(printjust1.dll). Is this as you would expect because Outlook crashed rather than just disabling the add-in?
Posted 15 Aug, 2018 07:03:15 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Mike,

Mike VE writes:
Now when I click the commend to show disabled COM addins both PrintJust1.AddinModule(adxloader) and printjust1.addinmodule(printjust1.dll).


Sorry? Are you saying that the COM add-in is disabled? Can you please send me a screenshot to the support email address?


Andrei Smolin
Add-in Express Team Leader
Posted 16 Aug, 2018 01:23:46 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Hi Andrei

I've been away a couple of days. I'm not sure what screenshot you want. When the add-in disables itself I then use Outlook's Disabled Items box to re-enable it than the COM Add-ins box to re-connect it. There is no reference to a COMAddin object in the code.
Posted 18 Aug, 2018 11:24:09 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Mike,

You mention two entities - PrintJust1.AddinModule(adxloader) and printjust1.addinmodule(printjust1.dll). I try to understand whether it is correct or not to have them. Could you please send me a screenshot of the File | Options | Add-ins dialog showing both of them? How many Office extension do you have in your solution?


Andrei Smolin
Add-in Express Team Leader
Posted 20 Aug, 2018 05:37:06 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Hi Andrei

I've sent details to the support address.
Posted 20 Aug, 2018 12:26:58 Top