I encountered the following error when trying to debug a new ObjectARX .NET assembly using Visual Lisp.
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.
This error would occur 95% of the time and pretty much took out AutoCAD each time it happened. Fortunately this can be disabled pretty easily within Visual Studio (I’ve tried both VS 2008 and VS 2010). In Visual Studio bring up the exceptions dialog from the Debug / Exceptions menu (or via the keyboard shortcut Cntrl D+E).
Expand the “Managed Debugging Exceptions” section and uncheck “LoaderLock” in the “Thrown” column. Next time you start AutoCAD from Visual Studio and load Visual Lisp you should no longer get this exception and you should be merrily debugging away.