((COleDispatchImpl*)&m_xDispatch)->Disconnect()
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
Hello, I am using a 3rd party SDK to display inventory of a machine; anyway after using the following code I close my application in debug mode and it throws an ASSERT error (listed below). This looks to me like the object either isn't being destroyed properly or the refrence count is incorrect for what ever reason... Any ideas?
IDatabasePtr ptr = NULL; IInventoryPtr inventory = NULL; int result = 0; CWaitCursor wait; try { ptr.CreateInstance(__uuidof(Database), NULL, CLSCTX_INPROC_SERVER); result = ptr->SetConnectionString(_bstr_t(strConnectionString)); if (result == 0) AfxMessageBox("Database connect failed."); else { try { inventory.CreateInstance(__uuidof(Inventory), NULL, CLSCTX_INPROC_SERVER); inventory->ShowInventoryTree(lComputerIDN); } catch (_com_error&) { AfxMessageBox("COM Error: Failed"); } } } catch(_com_error&) { AfxMessageBox("COM Error: Failed"); }
Here's the error in debug.
CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&m_xDispatch)->Disconnect(); ASSERT(m_dwRef <= 1); ////////// <---------- HERE #endif #ifdef _AFXDLL m_pModuleState = NULL; #endif }
Whoever said nothing's impossible never tried slamming a revolving door! -- modified at 11:06 Tuesday 21st February, 2006