« Amazing post on startup & shutdown | Main | Managing Part Libraries With Linked Blocks »

LoaderLock MDA warning in VS 2005 beta 2

After making some fairly innocuous changes, I started getting the following error dialog during application startup running within the VisualStudio 2005 beta 2 IDE:

LoaderLock was detected

Message: Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function.

See C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\sdk\bin\mdaBoilerplate.exe.mda.config for documentation.

 

Commenting out the code executing at the time of the exception moved it to a new location in the startup code.

I tested the same code built on a second PC with similar general configuration (but obviously many minor differences) and the problem did not occur.

So I followed the instructions in the MSDN help article referenced by the error dialog…

Added this key:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]

"MDA"="0"

Following this article:

ms-help://MS.VSCC.v80/MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxdebug/html/76994ee6-9fa9-4059-b813-26578d24427c.htm

This masks the problem. I don’t know if it was a bug in the detection code or a bug in the initialization code that just happens to skate by if ignored. I suspect the later.

A bit scary.

 

 

Comments

I get the same problem and not sure why it's annoying though, it may have something to do with protected variables and/or overides dunno.

Under Visual Studio 2005 there's a much more elegant way of handling this:

On the Debug Menu, Exceptions dialog, tree view Managed Debugging Assistants branch.

All of the MDA related exceptions are listed so you can easily disable those you have to.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)