G
Guest
Hi,
I wrote a mixed-mode dll (with MFC and C++/CLI) which is called from a C#-EXE.
Under special cirumstances (that is: another process sends a windows-message
to my process - this message is processed by the native part and calls
managed code in turn) a loader lock appears.
I have tracked down the call stack - the interessting part:
- mscorwks.dll (where the exception is raised)
- ... (left out in mscorwks.dll)
- my.dll!InternalDllMain (hInstance, dwReason=3, lpReserved=NULL)
- my.dll!DllMain (hInstance, dwReason=3, lpReserved=NULL)
- my.dll!__DllMainCRTStartup (hDllHandle, dwReason=3, lpReserved=NULL)
- my.dll!_DllMainCRTStartup (hDllHandle, dwReason=3, lpReserved=NULL)
- mscoree.dll!__CorDllMain@12
... (left out)
- kernel32.dll!ExitThread()
Of course - "my.dll" is my mixed-mode project, but all lines mentioned in
the call-stack are directly from mfc. "InternalDllMain" somehow calls
mscoree.dll with:
AFX_MANAGE_STATE(&afxModuleState); (Line 195 in dllmodul.cpp of mfc)
So, indirectly MFC calls managed-functions from within DllMain. Even more
interessting: The Loader-Lock is reported though DllMain was called for a
"Thread Detach" (dwReason==3), so the loader lock problem should normally not
apply ...
Does anyone know a solution to this?
Thanks in advance!
Jörg Mehlbrech
I wrote a mixed-mode dll (with MFC and C++/CLI) which is called from a C#-EXE.
Under special cirumstances (that is: another process sends a windows-message
to my process - this message is processed by the native part and calls
managed code in turn) a loader lock appears.
I have tracked down the call stack - the interessting part:
- mscorwks.dll (where the exception is raised)
- ... (left out in mscorwks.dll)
- my.dll!InternalDllMain (hInstance, dwReason=3, lpReserved=NULL)
- my.dll!DllMain (hInstance, dwReason=3, lpReserved=NULL)
- my.dll!__DllMainCRTStartup (hDllHandle, dwReason=3, lpReserved=NULL)
- my.dll!_DllMainCRTStartup (hDllHandle, dwReason=3, lpReserved=NULL)
- mscoree.dll!__CorDllMain@12
... (left out)
- kernel32.dll!ExitThread()
Of course - "my.dll" is my mixed-mode project, but all lines mentioned in
the call-stack are directly from mfc. "InternalDllMain" somehow calls
mscoree.dll with:
AFX_MANAGE_STATE(&afxModuleState); (Line 195 in dllmodul.cpp of mfc)
So, indirectly MFC calls managed-functions from within DllMain. Even more
interessting: The Loader-Lock is reported though DllMain was called for a
"Thread Detach" (dwReason==3), so the loader lock problem should normally not
apply ...
Does anyone know a solution to this?
Thanks in advance!
Jörg Mehlbrech