The information in this article applies to:
SYMPTOMSTwo errors can occur when using the MFC DAO database classes in a DLL. Depending upon the context of how you use the MFC DAO classes in the DLL, you can receive an assertion on line 36 of the Daocore.cpp or you may receive an access violation. CAUSE
The root of the problem exists in how MFC is terminating DAO. MFC calls
AfxDaoTerm from the exit instance of CWinApp. This is fine for applications
but isn't a good thing to do for DLLs because ExitInstance() is called from
the DLL_PROCCESS_DETACH case. Use of OLE and specifically DAO should be
avoided in the ExitInstance() of a DLL.
You can see that if an exception occurs in Release(), the m_pDAODBEngine
pointer is not set to NULL. Thus, the assert on line 36 of Daocore.cpp will
occur:
An access violation can occur if you perform the following sequence:
There may be other scenarios that can cause other access violations to occur. For example, do not create global MFC DAO objects within a DLL. The resolution section below doesn't address this problem because it is something that should not be done. RESOLUTION
To work around the problems with DAO in a DLL, do one of the following:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ 4.1. REFERENCESFor more information about problems using DAO in DLLs, please refer to the following articles in the Microsoft Knowledge Base: Q149889 PRB: Assertion or Problems Using DAO in a DLL Additional query words: kbVC400bug
Keywords : kbDAO kbDatabase kbMFC kbVC kbVC410fix |
Last Reviewed: August 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |