Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"LoaderLock was detected" with Visual Studio 2012

Tags:

I have a couple of MVC projects which use SQL CE 4.0 and Entity Framework. Since moving to Visual Studio 2012 I keep getting the following error (not every time, but frequently)

LoaderLock was detected

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.

The error does not occur if I go back to using VS 2010, which makes me fairly certain it is an issue with Visual Studio rather than my code, but I would like someone to confirm that for me!

Edit

The problem always seems to occur when the Dispose() method of the dbcontext is called. Here is a screenshot of the Exception Assistant:

Exception Assistant

like image 395
Darren Avatar asked Oct 15 '12 16:10

Darren


1 Answers

I switch this off. As it is warning that the application could hang, if your program doesn't hang, then you're probably fine.

The problem can be solved in the same way though, by switching off the MDA:

Debug -> Exceptions -> Managed Debug Assistants

and unchecking the LoaderLock item.

like image 82
harriyott Avatar answered Sep 20 '22 16:09

harriyott