Releasing context in Outlook context menu PropertyChanging event handler

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

Releasing context in Outlook context menu PropertyChanging event handler
 
Sven Knauer




Posts: 6
Joined: 2016-01-21
Hi.

In the article https://www.add-in-express.com/docs/net-ribbon-components.php#context you mentioned we should not release the COM objects in case of the PropertyChanging event.

You retrieve and release the context object in these ways:

in action events such as Click and Change, you use the IRibbonControl parameter to retrieve IRibbonControl.Context; you must release this COM object after use;
in the PropertyChanging event (see Updating ribbon controls at run-time), the context is supplied in the IRibbonControle.Context parameter; since the COM object is supplied in the parameters of the event handler, you must not release it.


The explanation somehow confusing for me. Would you clarify it, please, or confirm that we SHOULD NOT release the Context in the PropertyChanging event handler, and in only that case?

Thank you.
Posted 18 Jun, 2018 04:21:00 Top
Andrei Smolin


Add-in Express team


Posts: 15919
Joined: 2006-05-11
Hello Sven,

The confusion is caused by our mistake: we haven't noticed a typo in that text; we'll fixed it later today. That text should read as follows:


- in action events such as Click and Change, you use the IRibbonControl parameter to retrieve IRibbonControl.Context; you must release this COM object after use;
- in the PropertyChanging event (see Updating ribbon controls at run-time), the context is supplied in the e.Context parameter; since the COM object is supplied in the parameters of the event handler, you must not release it.


Yes, since Add-in Express provides that COM object to you, you shouldn't release it.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Jun, 2018 05:18:47 Top
Sven Knauer




Posts: 6
Joined: 2016-01-21
Hello Andrei,

thank you for the quick response.

Best Regards,
Sven
Posted 18 Jun, 2018 05:36:24 Top
Andrei Smolin


Add-in Express team


Posts: 15919
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Jun, 2018 06:05:00 Top