Re: ATL dll failing to load in VB

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




<pulkit.gaur@xxxxxxxxx> wrote in message news:e6b09fa3-821a-4bf7-b65b-544968011c5a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Brian ..


Well .. my dll is in debug mode

Copied the code of the lib inside my new dll.

Now the problems boils down to the call of my wrapper dll.

i get exception saying - Access violation reading location 0x00000000
in the
dllmain() of my wrapper dll whenever it gets called.

here is the code frag ..

=====================================================
struct cInfo
{
int nCamN;
IBaseFilter *pCap;
IBaseFilter *pSG;
CoSGCB *pSGCB;
dsCallBack *pCB;
CamInfo () : pCap(NULL), pSG(NULL), pSGCB(NULL), pCB(NULL) {};
};

static __declspec( thread ) vector<cInfo> *pinfo;


BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CoInitialize(0);
pinfo = new vector<cInfo>; { here i get exception }
..........
...............................
............

=======================================================
-

dinmith

I see you just posted this in the MSDN Forums at

http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/c3a86583-2567-420c-9ab2-b4baea50fb6a

and I've answered it there:

You are breaking a number of rules. Please re-read the documentation on DllMain() carefully. You can only carry out very primitive operations when attaching a DLL. And certainly there is no point in calling CoInitialize(), since the thread that loads the DLL may not be the thread that calls into the DLL later on. Either the client must call CoInitialize, or you will have to call CoInitialize...CoUninitialize() on each call into the DLL.


.



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: Calling a Activex control from a DLL
    ... Note that CoInitialize does explicitly state that it cannot be called from the DllMain ... CoInitialize/Unitializein the DLL anyway? ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: How to get imagebase after a DLL gets loaded
    ... and William provided a sensible answer. ... assigned-to during DllMain PROCESS_ATTACH." ... The OP asked "how to get imagebase after a DLL gets loaded". ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to get imagebase after a DLL gets loaded
    ... and William provided a sensible answer. ... assigned-to during DllMain PROCESS_ATTACH." ... The OP asked "how to get imagebase after a DLL gets loaded". ...
    (microsoft.public.win32.programmer.kernel)
  • Re: How to get imagebase after a DLL gets loaded
    ... and William provided a sensible answer. ... assigned-to during DllMain PROCESS_ATTACH." ... The OP asked "how to get imagebase after a DLL gets loaded". ...
    (microsoft.public.win32.programmer.kernel)