Loader Lock was detected exception in Visual Stodio

Many developers have experienced an annoying behavior while debugging in Visual Studio that leads to force termination of debugging session. The LoderLock was detected error popped up while debugging application in Visual Studio IDE. It will be a very expensive task for a developer to reinitiate the entire debug activity and re-test once again. In this article we will see how to avoid this exception in order to continue with smooth debugging.

Platform: Windows

What is the Error?

The loader Lock exception is displayed when the step-through debugging (F10/F11) in progress. This exception is displayed from managed debugging assistants and makes the user force terminate the debugging session when this kind of exception occurred.

LoderLock was detected error in Visual Stodio:

LoderLock was detected


Basically, the system runs the code in DllMain inside a lock (synchronization lock). Therefore, running non-trivial code inside DllMain is “asking for a deadlock”. For more details please read the article here.


Please follow the below steps to avoid loader lock exceptions from your debugging environment.

Open the Exceptions screen in Visual Studio IDE, by navigating to menu Debug -> Exceptions or hitting Ctrl+D+E short keys.
LoderLock was detected

On Exceptions screen, select and expand the “Managed Debugging Assistants” list.
LoderLock was detected

In the Managed Debugging Assistants list, find the “LoaderLock” option. The LoaderLock option is, by default, checked. Uncheck this option to disable the LoderLock exception.
LoderLock was detected

Click on OK button to save the changes. After making this configuration change, your debugging session will never encounter a LoderLock exception.

– Article ends here –

If you have any questions, please feel free to share your questions or comments on the comment box below.

Share this:
We will be happy to hear your thoughts

      Leave a reply