loader lock

I have an app that uses unmanaged code in the form of an OCR dll. The OCR sometimes spends a lot of time without relinquishing control and that seems to be causing me to get a "LOADERLOCK" exception. I tried setting the environment variable COMPLUS_MDA=0 as suggested in the documentation but that made no difference. I then set the registry value [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework] "MDA"="0" as also suggested and that worked better. (Ididn't crash so quickly).

However I really don't know what the error means or why I am doing these things and especially don't know if this exception will arise in a production version. Can anyone tell me what the future might hold in the area of this exception arising in my app

thanks
jim murray



Answer this question

loader lock

  • akira32

    This warning should only appear if your clients run your app in a debugger. Is that a realistic scenario To permanently remove the warning, you'll have to dig into the code and look at the DllMain() entry points. If you use ATL, you'll have to start using the new module classes. If you suspect that this warning is triggered by code from a 3rd party vendor (not unlikely), you'll have to contact that vendor for a fix. To move past this point, you'll have to tell us more about your app...


  • Lars E.Nes

    I have tried disabling the mda, as suggested, but the disabling was not permanently effective. The environment variable did not work at all and the registry variable worked until I re-activated my screen by moving the mouse after a long period (2 hours+) of screen saver while running in debug mode. The app is intended to be unattended, OCR'ng documents in the background, and never ending. My concern is that the 'loaderlock' false or not, will arise, stop the program and no-one will know it. Another concern I have is the volume of phone calls I will receive wanting to know if I have fixed it yet.

    Is there an exception thrown that I can catch and restart the OCR
    Is this problem being worked on



  • Aquilo

    It is very unlikely that an unmanaged DLL would cause a loader lock. Loader locks occur when a DLL gets loaded and it initializes the .NET framework runtime in its entry point (DllMain()). This problem only occurs at startup, you'll hear a "ding" from the speakers and your program locks up solidly. An unmanaged DLL wouldn't do this.

    You probably got the LoaderLock warning from an "MDA", a Managed Debugger Assistant. Unfortunately, this assistant tends to give false warnings. It sees a DLL using the framework when it gets loaded but doesn't realize that it is already initialized by your main program and thus cannot cause a loader lock. Just ignore the warning. Or check the link I gave in this thread to see how to disable it.


  • loader lock