views:

39

answers:

1

I have created a member variable in class as

CComPtr<IXMLDOMDocument2> m_spXMLDoc;

XML document is created as

CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument2, (void**)&m_spXMLDoc));

Now when application exits ,exception is occurring.Callstack is pointing to p->Release()

~CComPtrBase() throw()
    {
        if (p)
            p->Release();
    }

When I hover over to p in VS , it points to some valid memory.

The last callstack points to exception in msxm6

msxml6.dll!3d6cXX03() 

Any suggestions , what could be the reason. I dont think its a CComPtr issue.

A: 

You should create the instance using the member functions of CComPtr:

m_spXMLDoc.CoCreateInstance(...)
DanDan