visual c++ - exception during destruction of CComPtr -


After

I have declared

as a member variable
  CComPtr & LT; IXMLDOMDocument2 & gt; M_spXMLDoc;  

The XML document is created like this

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

Now when the app is released, an exception is thrown. Callstack points to p-> Release ()

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

When I P VS In the debugger, hover over it to point to some legitimate memory.

The last callstack for the exception is msxm6

  msxml6.dll! 3d6cXX03 ()  

Any suggestions, what could be the reason? I do not think it's a that CComPtr issue.

I had a similar issue and in the end I found that this is just a bug. I have to make sure that CoUninitialize () is called after CComPtr has been deleted. Otherwise, one exception would be.

  int _tmain (int argc, _TCHAR * argv []) {co-initial (null); My main (); // Put all the arguments in a different function so that CComPtr // is deleted before CoenInalize () CoUninitialize (); Return 0; }  

CComPt declared in the same function as CoUninitialize () will cause the exception of the call because the destruction occurs after the ceremony Is finished


Comments