Order of events while initializing Add In Express for Outlook mailto link

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

Only registered users are allowed to subscribe.
Order of events while initializing Add In Express for Outlook mailto link
PropertyChanged even fired before add in initialize method. 
Gutek Jakub




Posts: 32
Joined: 2017-06-06
Hi,

I have a situation in outlook 2007. When outlook is closed, and user clicks on mailto link on web page, outlook opens new mail and following order of events is happening:


2018-01-16 10:25:35.4027|TRACE|AddinModule|Constructor|End 
2018-01-16 10:25:36.6975|ERROR|OnOutlookClassificationButtonPropertyChanged| System.NullReferenceException: Object reference not set to an instance of an object.
   at AddinModule.OnOutlookClassificationButtonPropertyChanged(Object sender, ADXRibbonPropertyChangingEventArgs e)
2018-01-16 10:25:36.8535|TRACE|AddinInitialize|Start 


More over, Property Changed is not fired after Add Initialize method finish. So if I need to do something to buttons on Property changed I can't.

the only way is to set some sort of flag and react on that in AddinInitilize method.

is there any other way to do it?

Kind regards
Posted 16 Jan, 2018 04:56:04 Top
Andrei Smolin


Add-in Express team


Posts: 14713
Joined: 2006-05-11
Hello Jakub,

The PropertyChanging event occurs on a Ribbon component only when Office is going to draw the corresponding ribbon control. Does the exception relates to your code or to the code of Add-in Express? Can you please provice the call stack?

You can identify starting Outlook in this way by Explorers.Count being zero.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Jan, 2018 05:54:47 Top
Gutek Jakub




Posts: 32
Joined: 2017-06-06
Hi Andrei,

No, this is not add in express exception. But in all tutorials you states to delay initialization of things into AddinModule_AddinInitialize. PropertyChanging event is using things that are initialize in AddinModule_AddinInitialize that's why there is null reference exception thrown.

Thanks for the tip with Explorer.Count. Will do that.

are there other events that can be called before AddinModule_AddinInitialize is called?

are there other situations that I should be aware of that when starting outlook in specific way, things can go crazy?

I'm already prepared for:
1) Send To | Mail recipient - no inspectoractive and new event
2) Send File from office application - no inspectoractive and new event
3) And now this, clicking mailto on links when outlook is closed - property changing called before initialization

thanks!
Posted 16 Jan, 2018 11:05:41 Top
Andrei Smolin


Add-in Express team


Posts: 14713
Joined: 2006-05-11
Hello Jakub,

I see. The very first event that occurs on the add-in module is either ADXAddinModule.AddinInitialize or ADXAddinModule.OnRibbonBeforeCreate. Which is fired first depends on the host application, its version and how you start it.

If the exception in your code doesn't [seemingly] relate to the order of these events, please provide the call stack.

Also note that other Outlook versions may behave differently in the scenario that you test.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Jan, 2018 04:01:59 Top
Gutek Jakub




Posts: 32
Joined: 2017-06-06
Hi Andrei,

thanks, I will see if OnRibbonBeforeCreate can be handled in this scenario for initialize whole application.

The callstack is as follow:


System.NullReferenceException: Object reference not set to an instance of an object. 
   at    Apreel.Office.Sodoco.AddinModule.OnOutlookClassificationButtonPropertyChanged(sender As Object, e As ADXRibbonPropertyChangingEventArgs)
   at    AddinExpress.MSO.ADXRibbonCustomControl.AddinExpress.MSO.IADXRibbonComponent.DoChangeProperty(propertyType As ADXRibbonControlPropertyType, value As Object&, context As Object, index As Int32)


It throws on executing method on class that is initialized in ADXAddinModule.AddinInitialize. In this case this object was not initialized as ADXAddinModule.AddinInitialize wasn't yet executed.

As for outlook, I know, thats why im only asking for outlook 2007 :)

Kind regards
Posted 17 Jan, 2018 04:34:21 Top
Andrei Smolin


Add-in Express team


Posts: 14713
Joined: 2006-05-11
Your diagnosis looks correct: I don't see anything contradicting it. Please let me know if I can help any further.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Jan, 2018 04:44:38 Top
Gutek Jakub




Posts: 32
Joined: 2017-06-06
thanks, just wonder if there is any other events that i should be aware of? if not then, cool, thanks
Posted 17 Jan, 2018 05:13:41 Top
Andrei Smolin


Add-in Express team


Posts: 14713
Joined: 2006-05-11
There's no other events involved in the issue above.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Jan, 2018 05:34:59 Top