LoaderLock was Detected when entering text in a Windows Form

When running my C# code in the debugger, I get a loaderlock MDA whenever I enter text in a windows form.

The MDA Text follows:

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.

It is not obvious from the stack dump how to fix this problem. [Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = -1, int pvLoopData = 0) + 0x1c3 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x17d bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x2e bytes
> VirtualLab.exe!VirtualLab.Client.MainForm.Main(string[] args = {Dimensions:[0]}) Line 3952 + 0xb bytes C#

Any ideas

Thanks, Jeff



Answer this question

LoaderLock was Detected when entering text in a Windows Form

  • Hugo

    Until it gets fixed you can de-activate the LoaderLock MDA by clicking Menu item: Debug, then Exceptions, them expanding Managed Debugging Assistants, then scroll down to Loader Lock and un-check it in the "thrown" column, and press OK.

    I do not know if it is an issue MS has to deal with or not but most forum sites give the above answer.


  • sprague295

    This is what we have done to work around the problem for now. I'm still wondering why this is happening and whether it might be a MS issue.
  • LoaderLock was Detected when entering text in a Windows Form