Re: ADO in dll AV

From: Viatcheslav V. Vassiliev (support_at_oledbdirect.com)
Date: 12/24/03


Date: Wed, 24 Dec 2003 09:49:54 +0300

It is better to include ComObj unit in main project - this will call
CoInitialize from main project.

This is from MSDN CoInitialize description:

Because there is no way to control the order in which in-process servers are
loaded or unloaded, do not call CoInitialize, CoInitializeEx, or
CoUninitialize from the DllMain function.

MSDN DllMain:

Warning The entry-point function should perform only simple initialization
or termination tasks. It must not call the LoadLibrary or LoadLibraryEx
function (or a function that calls these functions), because this may create
dependency loops in the DLL load order. This can result in a DLL being used
before the system has executed its initialization code. Similarly, the
entry-point function must not call the FreeLibrary function (or a function
that calls FreeLibrary), because this can result in a DLL being used after
the system has executed its termination code.

//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi + ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)

"Brian Bushay TeamB" <BBushay@Nmpls.com> ???????/???????? ? ????????
?????????: news:da6iuvs5njbak1os39f2h1bgkr8eicjoho@4ax.com...
> >When the DataModule (DM_Main) has no Ado component on it, it works fine.
But when I add a TAdoConnection object on it, I get an AV when calling the
exported function.
> >
>
> Are you calling CoInitialize in the Initialization section of the DLL?
ADO is
> uses COM and in a DLL you need to manage initializing COM
>
>
> --
> Brian Bushay (TeamB)
> Bbushay@NMPLS.com



Relevant Pages

  • Re: operator new[] fails in DLL when being called from within VB6 process
    ... its initialization graph, it may work one day, and the next day you'll start ... DllMain being called before ole32's DllMain. ... > But btw - calling CoInitialize() in DllMainis actually very forbidden ... >> I can't remember the details, and our DLL is a complex multi-threaded RPC ...
    (microsoft.public.win32.programmer.kernel)
  • Re: operator new[] fails in DLL when being called from within VB6 process
    ... and our DLL is a complex multi-threaded RPC ... importing our standard client/server WINAPI based dlls. ... You would call CoInitialize() in DLL_PROCESS_ATTACH and you would call ... > loaded into a VB6 process? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CoUninitialize() and CComPtr<> object lifetimes
    ... > seems that the destructor for my CComPtr<> is not being called until ... It does not help that CoInitialize() is being called ... called when the DLL is loaded, and its destructor - when the DLL is ... loaded until CoUninitialize. ...
    (microsoft.public.vc.atl)
  • Re: Serious bug in .NET framework 2.0 - IShellLink interface crashes
    ... I wrote a managed C++ console app ... CComPtrpLink; ... What should be the problem with CoInitialize? ... As I wrote I call it in the constructor of the managed C++ DLL. ...
    (microsoft.public.dotnet.framework)
  • Re: Help wanted: CL, ASDF, and MSWin shortcuts
    ... see whether your CoInitialize is actually the first call that did the COM ... initialization for this thread, and only in that case do the CoUninitialize. ... call to `CoInitialize' was successful. ...
    (comp.lang.lisp)