CDaoDatabase in COM Component Problem 
Author Message
 CDaoDatabase in COM Component Problem

I have a possible bug in DAO when used in an ATL component.

To work out if it was my own code or not I created an ATL Simple COM
component with one interface and one method in that interface. It has
MFC support and includes afxdao.h.

I then created a dialog based MFC app with a single button that just
creates an instance of the component, gets the interface, calls the
method, and releases everything.

The method in the component just does this...

STDMETHODIMP CDaoTestObj::OpenAndClose(BSTR bstrFileName)
{
        AFX_MANAGE_STATE(AfxGetStaticModuleState())

        TRACE0("OpenAndClose\n");

        try
        {
                CDaoDatabase* pDB=new CDaoDatabase;

                pDB->Open((LPSTR)_bstr_t(bstrFileName));

                pDB->Close();

                delete pDB;
                pDB=NULL;
        }
        catch(CException* pe)
        {
                pe->ReportError();
                pe->Delete();
        }

        TRACE0("OpenAndClose Finished\n");

        return S_OK;

Quote:
}

I run the app, press the button, it works fine, then I exit the app and
I get a "DAOTESTCLIENT caused an invalid page fault in module
KERNEL32.DLL at..."

This happens regardless of whether I have an AfxDaoTerm() call or not,
and I've tried it after the delete pDB in the method, in the
DllCanUnloadNow() in the component, in the ExitInstance(), etc.

The same symptoms occur in the Component I've written which
successfully creates from scratch and manipulates DAO databases - ie:
everything works perfectly until the application terminates and the
component unloads.

It's also an extremely painful thing to try and debug because the
exception occurs in the system dll where it can't be traced, and it's
one that you can't close/terminate/stop debugging, so that files are
locked open, and so the machine needs rebooting before anything can
proceed.

I'm using VC 6.0 on Windows 98.

--
Nev Delap

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Mon, 18 Feb 2002 03:00:00 GMT  
 CDaoDatabase in COM Component Problem
PS: Deja converted the tabs to spaces. That's not how I format my code.
Nev.

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



Mon, 18 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using CDaoDatabase/CDaoRecordset from inside an ATL/MFC COM Component

2. COM Component w/o Component Services

3. COM Components to be listed in available Components of Packe wizard

4. Problem Register COM Component in COM+(VC7,W2K)

5. ATL COM component is giving a list of problems

6. Problem using COM components in VB

7. VC++/ATL COM ASP component thread problem.

8. Problem Register COM Component in COM+(VC7,W2K)

9. Problems with COM component calling dll

10. ADO COM component problem

11. Problems with a com inprocess component project

12. Problem with a com inprocess component project

 

 
Powered by phpBB® Forum Software