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:
Reason:
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.
Solution:
Please follow the below steps to avoid loader lock exceptions from your debugging environment.
1
Open the Exceptions screen in Visual Studio IDE, by navigating to menu Debug -> Exceptions or hitting Ctrl+D+E short keys.

2
On Exceptions screen, select and expand the “Managed Debugging Assistants” list.

3
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.

4
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 –