Accessing Count property calls Release()

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.
 
E

Eric

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top