Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ((COleDispatchImpl*)&m_xDispatch)->Disconnect()

((COleDispatchImpl*)&m_xDispatch)->Disconnect()

Scheduled Pinned Locked Moved C / C++ / MFC
databasecomdebugginghelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RobJones
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups