Thursday, May 24, 2007

Loader Lock exception in windows applications

Blatantly ripped from:

Error Message:

LoaderLock was detected
Message: DLL '.......\Microsoft.DirectX.Direct3D.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.A Loader lock is one of the Managed Debugging Assistants (MDAs) that were added to VS2005 to help find hard to debug runtime issues. There is code in all Managed DirectX 1.1 assemblies that causes this MDA to fire. Microsoft have confirmed they are aware of the problem. However I do not expect to see a fix for MDX 1.1 since current efforts are focused on MDX2.0/XNA Framework, it ONLY affects code run under the debugger (i.e. it won't happen when users run your EXE) and there is a trivial workaround. I'm not sure of exact reproduction steps - it appears to fire on some projects and not on others.

To work around the problem you have several choices:

Go back to using VS2003 and .Net 1.1
Use MDX 2.0. Note that MDX 2.0 will never actually ship as it is being transformed into the XNA framework.
Disable the loader lock MDA. Debug/Exceptions (ctrl-D, E), Open the Managed Debugging Assistants tree node and uncheck Loader Lock. This setting is per solution so it will only affect this solution.
Versions affected:All .Net 1.1 Managed DirectX assemblies when used with Visual Studio 2005 and .Net 2.0.

My apologies, but I will get around to writing my own piece on this particular exception and it's foibles myself when I've got time!

No comments:

Post a Comment