Thread: ADO/COm error?

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    Swindon, UK
    Posts
    0
    Rep Power
    0

    Question ADO/COm error?


    Hi,

    I'm trying to create an extension dll that references a database via ADO, using VC 6. The problem comes when the application is exited and it spits up the following error:
    'Unhandled exception in <application> (MSDART.DLL) 0xC0000005: Access Violation'

    Currently the connection object is a global, to an exported class that I'm using as a layer between the application and the database. This object is created, opened, (no transactions are run against it yet) then closed, detached and finally set to null, which should destroy it. In addition ::CoInitialize and ::CoUninitialize are called in the constructor and destructor of this class.

    The call stack doesn't list my application, but does list ~com_ptr_t(), which I am assuming would be a COM destructor? So is the OS trying to access the object that was in my dll? If so why/how do I get around it?

    Any help or pointers would be greatly appreciated.

    TIA
    2c
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Nebraska
    Posts
    0
    Rep Power
    0

    Angry


    I'm experiencing the same error.

    When I run the exact same code in a EXE as compared to inside a DLL it works fine with no exit problems.

    I get the exception on the Rlease function.

    void CADORecordset::Close()
    {
    TRACE("Beginning CADORecordset::Close()\n");
    try
    {
    if(IsOpen())
    {
    if (m_nEditStatus != dbEditNone)
    CancelUpdate();

    m_pRecordset->PutSort(_T(""));
    m_pRecordset->Close();
    }
    }
    catch(_com_error &e)
    {
    dump_com_error(e);
    ProviderError(m_pConnection);
    }
    catch(CException &e)
    {
    char zCause[256];
    e.GetErrorMessage(zCause, 255);
    TRACE("CException %s\n",zCause);
    }
    catch(...)
    {
    TRACE("Caught unknown error in CADORecordset::Close()\n");
    }
    TRACE("Ending CADORecordset::Close()\n");
    }


    ~CADORecordset()
    {
    TRACE("~CADORecordset()\n");
    Close();
    try
    {
    if(m_pRecordset)
    {
    TRACE("Release Recordset!\n");
    m_pRecordset.Release();
    m_pRecordset = NULL;

    }
    m_pRecBinding = NULL;
    m_strQuery = _T("");
    m_csLastError = _T("");
    m_dwLastError = 0;
    m_nEditStatus = dbEditNone;
    }
    catch(_com_error &e)
    {
    dump_com_error(e);
    ProviderError(m_pConnection);
    }
    catch(CException &e)
    {
    char zCause[256];
    e.GetErrorMessage(zCause, 255);
    TRACE("%s\n",zCause);
    }
    catch(...)
    {
    TRACE("Caught unknown error in ~CADORecordset.\n");
    }
    }

    Using the try/catch loop I'm able to get past the error for the moment, but I'm unclear as to why it's happening or yet how to really fix it. Please let me know if you find a solution...

    I've been searching the Microsoft databases but haven't had much luck at finding any information on the ADO/DLL problem.

    The version of the MSDART.DLL I'm running is is version 2.71.9030.0, when I looked up the DLL on Microsft's site they said the latest was 2.71.9031.4. Are you running the same one?

    What version of the MDAC do you have installed? I believe I'm running the 2.7 SP1(WinXP) version though mdac component checker, doesn't completely see DLL's correctly, all the registy entries and com details appear fine as well as the ODBC and OLEDB entries.

    I did find, Microsoft Knowledge base article 272373..
    Access Violation occurs when closing ADO recordsets in multithreaded applications. It talks about a high stress on a mulipleprocessor computer. I don't have that, but the dll I wrote is under high stress as thousands of callbacks a second maybe happening. It said the problem should have been corrected in 2.7 MDAC, so the article was all that useful..

    I've tried adding a sleep call to slow down the destruction, and even tried writing a function call to shut down early before the normal destruction..
  4. #3
  5. jasondoucette.com
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada
    Posts
    378
    Rep Power
    12
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    0
    Rep Power
    0

    Question unhandled exception (MSDARD.DLL)


    Hi Abomination ! First sorry for my English.

    I have met same problem (exception from msdart.dll)!
    Have you solved the problem ?
    If YES, please tell me how.

    I try to explain my situation :
    I made an DLL and I created a few functions:

    At top of file source (cpp) I declarated :

    #import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
    no_namespace rename("EOF", "EndOfFile")
    _RecordsetPtr pRS;

    pRS is visible in all file .

    An example for function's declaration :

    void _declspec (dllexport) Func1(args)

    In an function I open a table using pRS.
    I'm assure to catch any exception and close pRS.

    When I exit from aplication , I see following error:

    'Unhandled exception in <application> (MSDART.DLL)


    Thank you in advance !

IMN logo majestic logo threadwatch logo seochat tools logo