Accessing Count property calls Release()

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

I'm using C++ to develop an Outlook COM Add-in. It appears that
anytime I access a "Count" property I need to call AddRef() before
doing so? Is this correct? It seems that accessing *ANY* "Count"
property must internally call Release() on the object. I've seen this
same behavior on the Application.Explorers object, and now on the
Application.Explorers.Selection object. If I don't call AddRef()
before I check the Count property, the object is release prematurely
(I'm pretty sure) and I get access violations when closing Outlook.
 
I figured it out myself, just a bone-head move. I wasn't clearing the
VARIANT type variable before using it again, so somewhere inside the
OLE or Outlook code it must have been clearing it for me, which
explains the Release() call on the object.
 
Back
Top