I keep getting this error and forgetting how to solve it, so time to blog.
When debugging in Visual Studio 2008 I sometimes get
Loaderlock was detected
DLL ‘c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f8542944\24ca7c20\assembly\dl3\83245f41\feb88c06_9e6eca01\someNaughty.DLL’ is 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.
The solution is to switch off the Managed Debug Assistant (MDA) for Loaderlocks.
Debug -> Exceptions -> Managed Debug Assistants and uncheck the LoaderLock item.
Thanks to Simon Harriyott post here for solving it.
I love the fact that the way to get around this error is rather than resolve the issue being flagged up, just turn off the debugger instead
we’re all guilty of doing similar things, I think.
Hahaha, good point!
To be honest I’ve no idea how to ‘fix’ the problem, but I know the DLL in question was written by us so I’m happy to ignore it lol