Sign in to follow this  
Trillian

That "LoaderLock" C# thingie

Recommended Posts

Hello! I've been learning C# while porting my engine for one week and a half now (without having the chance to compile since yesterday :D). So, everything builds fine. I've created an application in order to test the actual engine. However, the program crashes. If I debug, MSVC# stops the program at some point displaying a "LoaderLock" warning message. The point where the program stops is in my engine's Cryo.Graphics.Direct3D9.DeviceFactory singleton (oh my god, a singleton!). The program crashes when I try to access the DeviceFactory instance and the static constructor is invoked in order to create the actual instance. However, in DeviceFactory's non-static constructor, calls are made to D3D9 in order to check device caps and such. The problem is that the loading of the Cryo.Graphics.Direct3D9 dll loads the official d3d9 dll and this creates the crash. "DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX.Direct3D\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.Direct3D.dll' is 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." I don't know how I could desing my code so this doesn't occur. COuld anyone help?

Share this post


Link to post
Share on other sites
I think you can pretty much safely ignore this exception/problem, and just disable the Loader Lock helper that Visual Studio provides. I too have had the problem when using C# and the now outdated MDX. Just go up into one of the menus, I can't remember which one, and find the Debugger Helpers and disable the Loader Lock helper. If you Google LoaderLock you can probably find tons of other people who have run into this as well.

Share this post


Link to post
Share on other sites
Oh thanks a lot! Now that this is put aside, I see that it actually is a NullReferenceException that crashed my app :D!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this