AddInInitialize fails to finish

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

AddInInitialize fails to finish
Addin Initialization 
AppDev




Posts: 26
Joined: 2016-06-22
Hello Andrei and team,

I hope you are all doing well. Let me get straight down to it :

#1. Currently we are having issues with some of our clients. In cases where the problem was observed, our Outlook addin loads but the code inside AddinInitialize() is never finished. I can say that the initialization is not finished because the icon, text, and other data are never updated (as reflected in my logs).


#2. I then modified the code to call initialization on both AddinInitialize() and OnRibbonBeforeCreate() which work perfectly fine in machines that did not have issues. But in machines where #1 happened, I received the following error :
===================================================================================================================================
Type TID DateTime TickCount(US) Message
===================================================================================================================================
Info 1 2020-02-06T06:47:41 637165684617963417 [AddinModule:.ctor]Constructor Started.
Info 1 2020-02-06T06:47:41 637165684618643027 [AddinModule:.ctor]Constructor Finished.
Info 1 2020-02-06T06:47:41 637165684619191325 [AddinModule:AddinModule_AddinInitialize]Add-in module AddinModule_AddinInitialize started.
Info 1 2020-02-06T06:47:49 637165684690879659 [AddinModule:AddinModule_OnRibbonBeforeCreate]Add-in module AddinModule_OnRibbonBeforeCreate started.

Error 1 2020-02-06T06:47:49 637165684690889630 Error thrown at xxxxxxxx
Error Message: Object reference not set to an instance of an object.
StackTrace: at xxxxxx.AddinModule.OlToysConnect_OnError(ADXErrorEventArgs e)
at AddinExpress.MSO.ADXAddinModule.DoError(Object sender, Exception e)
at AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IRibbonExtensibility.GetCustomUI(String RibbonID)
DetailedNotes: System.NullReferenceException: Object reference not set to an instance of an object.
at xxxxxx.AddinModule.OlToysConnect_OnError(ADXErrorEventArgs e)
at AddinExpress.MSO.ADXAddinModule.DoError(Object sender, Exception e)
at AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IRibbonExtensibility.GetCustomUI(String RibbonID)

Info 1 2020-02-06T06:48:23 637165685030647858 [AddinModule:AddinModule_OnRibbonBeforeCreate]Add-in module AddinModule_OnRibbonBeforeCreate started.
Error 1 2020-02-06T06:48:23 637165685030658093 Error thrown at xxxxxxxx
Error Message: Object reference not set to an instance of an object.

StackTrace: at xxxxxx.AddinModule.OlToysConnect_OnError(ADXErrorEventArgs e)
at AddinExpress.MSO.ADXAddinModule.DoError(Object sender, Exception e)
at AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IRibbonExtensibility.GetCustomUI(String RibbonID)

DetailedNotes: System.NullReferenceException: Object reference not set to an instance of an object.
at xxxxxx.AddinModule.OlToysConnect_OnError(ADXErrorEventArgs e)
at AddinExpress.MSO.ADXAddinModule.DoError(Object sender, Exception e)
at AddinExpress.MSO.ADXAddinModule.AddinExpress.MSO.IRibbonExtensibility.GetCustomUI(String RibbonID)

#3. Do you have any idea at all what is causing my initialization to hang? And why it crashes if initialization is called twice? I cannot debug this on my machine as this happens only in a very select few of our clients and in a very select group off outlook accounts.

#4. Do you have any advice for me how to move forward? Do you have a guide on how to make an empty/bare outlook addin using your libraries, so I can use that and then see if the problem persists even with "bare/empty" addis?

I hope I am making sense. Thanks
Posted 10 Mar, 2020 23:51:47 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello AppDev,

It is very difficult to find the cause of an error if you don't have any code to look at. Did you try to debug this? Do you get any exceptions in your code?

I suppose that an empty add-in showing Ribbons doesn't produce this issue. If so, let me list the points that you should be be aware of.

You shouldn't access any object model from a thread other than the main one. It is okay to use a thread to calculate something; it isn't okay to scan Outlook items, Excel cells, etc. in a background thread. Note that ADXRibbon*, ADXBackStage*, and descendants of ADXCommandBar use the Office object model behind the scenes. Meaning, you shouldn't use them on a thread. Do not use Task<>.Run to access any object model. An aaways

You shouldn't initialize any complex-type variables declared on the class-level. Instead, initialize them in an event of the add-in module. The very first event that the module receives is either AddinInitialize or OnRibbonBeforeCreate.

Do not use DoEvents. Do not use an await operator with ConfigureAwait(false). These things may switch the context while your code isn't aware of this.


Andrei Smolin
Add-in Express Team Leader
Posted 11 Mar, 2020 05:26:18 Top
AppDev




Posts: 26
Joined: 2016-06-22
Hello Andrei,

Thank you for your response.

The biggest problem I have right now is that I cannot reproduce this issue in any of my machines. And it's been a long time since I started looking into this issue. After finally talking with a client and having the code at a level of stability I wanted, I was able to see how the client reproduced it. I tried again on all my available machines and VMs and could not reproduce it still.

Anyways, point being, I am thinking of creating an "empty" addin that still uses the addin express libraries and see how it goes. I will also keep these points in mind. The biggest issue right now is the hanging of the initialization code.

Aside from the above do you have any other advise as well? This bug started around April 2019. Anything special with that time frame?

Thank you very much!!
Posted 11 Mar, 2020 07:37:05 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Debugging! This is what you need. You can add a number of debug messages to your code; use System.Diagnostics.Debug.WriteLine(). If the add-in is built in the Debug configuration, you collect the messages at run time using DebugView (see http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx).


Andrei Smolin
Add-in Express Team Leader
Posted 11 Mar, 2020 07:46:44 Top