What's up with this new Loader Lock exception?
-
I'm getting an exception that looks like below when my debug C# app calls into my debug C++ dll (which uses the MS CRT, debug dll). Apparently if I go to the Menu>Debug>Exceptions>Managed Debugging Assistants and unchecked Loader Lock checkbox, the exception goes away but I get a message saying that I'm trying to use a dll that's loading the CRT without a manifest file. This must all be part of this new manifest side-by-side stuff that is introduced in VS2K5. However I am not getting this problem when I run the release build of my solution and I cannot for the life of me figure out what Microsoft wants you to do here. All I want to do is call into my dll, why has this become so hard to do in the new version of VS.NET ??
Loader Lock was detected: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
-- modified at 18:14 Monday 5th December, 2005 -
I'm getting an exception that looks like below when my debug C# app calls into my debug C++ dll (which uses the MS CRT, debug dll). Apparently if I go to the Menu>Debug>Exceptions>Managed Debugging Assistants and unchecked Loader Lock checkbox, the exception goes away but I get a message saying that I'm trying to use a dll that's loading the CRT without a manifest file. This must all be part of this new manifest side-by-side stuff that is introduced in VS2K5. However I am not getting this problem when I run the release build of my solution and I cannot for the life of me figure out what Microsoft wants you to do here. All I want to do is call into my dll, why has this become so hard to do in the new version of VS.NET ??
Loader Lock was detected: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
-- modified at 18:14 Monday 5th December, 2005Compile the assembly with /NOENTRY (IIRC). IOW you cant use managed code inside DllMain. xacc.ide-0.1 released! Download and screenshots
-
Compile the assembly with /NOENTRY (IIRC). IOW you cant use managed code inside DllMain. xacc.ide-0.1 released! Download and screenshots
Well that changed the way the error was thrown, but it looks to be throwing the same error. Here's what it is saying:
Managed Debugging Assistant 'LoaderLock' has detected a problem in 'D:\Dev\throwaway\pinvoke\pinvoke\bin\Debug\pinvoke.exe'. Additional Information: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.[/code] Here is what my DllMain looks like, but again why isn't this happening with my release version? `BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }`