OutlookItemEventsClass reference count

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

OutlookItemEventsClass reference count
How do I get the current reference count 
German Hayles




Posts: 41
Joined: 2015-04-27
I use the following format

OutlookItemEvents( theOutlookObject, true )


When RemoveConnection() is called, is there a way for me to get the current reference count on that object?

I'm looking for something similar to


int iRefCount=0xFFFFFFFF;
iRefCount = Marshal.ReleaseComObject( theOutlookObject);
Posted 23 Aug, 2017 17:59:49 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello German,

This isn't possible if you call ADXOutlookItemEvents.ConnectTo(..., true). If you call ADXOutlookItemEvents.ConnectTo(..., false), you will be able to call Marshal.ReleaseComObject() and get the reference count.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Aug, 2017 03:21:01 Top
German Hayles




Posts: 41
Joined: 2015-04-27
Ah. Clever API!
Posted 24 Aug, 2017 07:21:28 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 24 Aug, 2017 07:27:23 Top
German Hayles




Posts: 41
Joined: 2015-04-27
Marshal.ReleaseComObject(...) never executes because ItemObj is always null after RemoveConnection().

Am I allowed to call Marshal.ReleaseComObject on ItemObj?


    int _mailItemRefCount = -1;
    public int MailItemReferenceCount { get{ return _mailItemRefCount; } }

    if (_ItemEvents.IsConnected == true)
    {
    
        _ItemEvents.RemoveConnection();
        if (_ItemEvents.ItemObj != null) { _mailItemRefCount = Marshal.ReleaseComObject(_ItemEvents.ItemObj); }
        log.Debug(string.Format("MailItem Reference count: {0}", MailItemReferenceCount));
    }
Posted 24 Aug, 2017 11:29:52 Top
German Hayles




Posts: 41
Joined: 2015-04-27
Please ignore my last post. I forgot that you're not supposed to release Add-In-Express Objects.
Posted 24 Aug, 2017 14:27:21 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
No problem.


Andrei Smolin
Add-in Express Team Leader
Posted 25 Aug, 2017 03:44:34 Top