[SOLVED] Strange LoaderLock issue


10-03-2007 09:01:24

I am getting a wierd LoaderLock MDA popping up when I am trying to run Root.Initialise. When the user of my app clicks a button, a create a render window, and attempt to initialize it. When I call Root.Initialise, it throws the LoaderLock error.

The code looks like:

Event handler:

private void m_GuiFileNew_Click(object sender, EventArgs e) {
Views.RenderView view = new Views.RenderView ();
view.InitializeEngine ();
view.Show (m_GuiDockPanel);

Initialise code:

public void InitializeEngine() {
m_Root = new Mogre.Root ();
m_Root.Initialise (false); // <-- LoaderLock happens here

Mogre.RenderSystem rs = m_Root.GetRenderSystemByName ("Direct3D9 Rendering Subsystem");
m_Root.RenderSystem = rs;
rs.SetConfigOption ("Full Screen", "No");
rs.SetConfigOption ("Video Mode", String.Format ("{0} x {1} @ 32-bit colour", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));

Mogre.NameValuePairList args = new Mogre.NameValuePairList ();
args["externalWindowHandle"] = this.Handle.ToString();
m_Root.CreateRenderWindow ("RenderView", (uint)this.ClientSize.Width, (uint)this.ClientSize.Width, false, args);

I know what causes LoaderLock, but why would attempting to load OgreMain.dll (which is what I assume Mogre.dll must be doing) cause LoaderLock? OgreMain.dll shouldn't be making any managed calls back up the stack, which is what tends to cause LoaderLock.


11-03-2007 18:22:23

Ahh, I am a dork. I was calling Root::Initialise before I setup the RenderSystem. It was actually throwing an SEHException (up from Ogre) that VS2005 was interpreting as a LoaderLock exception.