locked
LoaderLock was detected RRS feed

  • Question

  • Hi,

    I have installed DirectX 9 SDK (October 2005) and Visual Studio 2005 RC1.

    When I try using directx classes for capture audio, I have a problem.

    The code i have wrote is:

    Dim d As DirectSound.Device
    Dim ds As DirectSound.CaptureDevicesCollection
    ds = New CaptureDevicesCollection
    For Each d In ds
              Me.ListBox1.Items.Add(d.ToString)
    Next

    When I run the application I get error when creating new instance of CaptureDevicesCollection.

    The error is : LoaderLock is detected.

    The MDA message is:
    LoaderLock was detected
    Message: DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.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.


    How resolve it?

    Thanks

    JMBC
    Girona

    Friday, October 21, 2005 2:03 PM

Answers

  • This is a known issue when using the MDX 1.1 assemblies against .Net 2.0.

    Your choices.
    1. Go back to VS2003
    2. Wait until the MDX for .Net 2.0 is released. There is a beta with the October SDK but as you may have heard there are significant problems. http://www.thezbuffer.com/articles/291.aspx
    3. In VS2005 go to Debug/Exceptions. OPen up the Managed Debugging Assistants node on the tree and scroll down till you find LoaderLock and uncheck it. This seems to get rid of the error most of the time, but a few folk have told me otherwise so I'm not sure. It always works for me.
    Friday, October 21, 2005 5:38 PM
  • That registry will pernamanently affect all solutions *and* turns off all MDAs. Much cleaner to just turn off the loaderlock MDA from inside visual studio which is per project. http://www.thezbuffer.com/articles/304.aspx

    Friday, February 17, 2006 5:04 PM

All replies

  • This is a known issue when using the MDX 1.1 assemblies against .Net 2.0.

    Your choices.
    1. Go back to VS2003
    2. Wait until the MDX for .Net 2.0 is released. There is a beta with the October SDK but as you may have heard there are significant problems. http://www.thezbuffer.com/articles/291.aspx
    3. In VS2005 go to Debug/Exceptions. OPen up the Managed Debugging Assistants node on the tree and scroll down till you find LoaderLock and uncheck it. This seems to get rid of the error most of the time, but a few folk have told me otherwise so I'm not sure. It always works for me.
    Friday, October 21, 2005 5:38 PM
  • Friday, February 17, 2006 2:06 PM
  • That registry will pernamanently affect all solutions *and* turns off all MDAs. Much cleaner to just turn off the loaderlock MDA from inside visual studio which is per project. http://www.thezbuffer.com/articles/304.aspx

    Friday, February 17, 2006 5:04 PM
  • My post was about VS 2005.

    I cannot find the exception settings in this VS version.

    Is it your solution valid also for Visual Studio 2005? And how?

    Thanks

    Friday, February 17, 2006 5:12 PM
  • Yes, MDAs are *only* in VS2005. The Debug menu doesn't appear until you have a project open. Otherwise I'm not sure why you can't find it. I just checked c# express and its there too, Debug menu, Exceptions...

    Friday, February 17, 2006 5:20 PM
  • Yes, I've looked at the debug menu with an open project....

    No Exceptions submenu... I've tried with a vb and a c# project.

    The only difference is that I have a VS2005 standard edition.

    Monday, February 20, 2006 8:25 AM
  • Well how about that, so VS standard doesn't have an exceptions dialog but the express products do... You might want to confirm that in the VS forums since it seems very odd to me. Do you remember which 'command set' you chose when you ran VS for the 1st time - it asks if you are a c#, VB, or web developer - I'm wondering if somehow the menu got hidden... Can you try to customize the menus and see if you can add it back in?

    But if that is the case, then I guess you are indeed stuck with using the registry - remember to turn it back on though since its not per project.

    Monday, February 20, 2006 6:30 PM
  • Just as information: My team suite edition with a C# 'command set’ contains the Exception dialog.  I will test this with the professional version on my other system tomorrow.

    EDIT: The professional version contains it too.

     

    Monday, February 20, 2006 7:56 PM
  • Solved!

    I try to customize the menu as u suggest, and voilà, I find it!!

    Thanks a lot to all

    Tuesday, February 21, 2006 8:13 AM
  • I had the same problem. I work now in an quite large legacy project. Our task was provide migration from FrameWork1.0SP3 to FrameWork2.0 and also DevExpress  dev line 1.X to dev line 6.X.

    After I've made all necessary changes to be able to compile the whole project without errors, on the screen appear message "LoaderLock was detected". This message appear 4 times. Then application was simply shuted down.

    I've spend some time to make some changes in debug properties, but unfortunately have no luck.

    Later I understand that the problem was here (debug output):

    "A first chance exception of type 'System.NullReferenceException' occurred in XXXXX.exe"

    The I've found to places where was somthing like this:

    //code starts

    Hashtable table;

    ...

    table["key"] = someValue;

    //code ends

    The problem was that the <table> has no key with "key" value.

    Maybe it can help some one.

    Friday, May 12, 2006 2:18 PM
  • i had the same problem before, and i uninstalled the vs2005 and reinstalled vs2005, problem has gone.
    Wednesday, December 6, 2006 4:45 PM
  • Use Ctrl-Alt-E and the Debug.Exceptions menu will open.
    Friday, February 2, 2007 10:29 PM
  • This is incredibly bizarre, but I've been working on a project this morning that's been running fine.

    I then install an update to ITunes / QuickTime (7.1).

    I then get the loadlock errors (appears to be when attempting to modify text in mask text boxes at the moment, not sure if that's exclusively though).

    Just tested in a project that has not been amended and was working perfectly and the same problem is now occuring.

    If I disable the MDA then the app just hangs rather than the exception being thrown.

    Could this be interaction between the ITunes update and VS?  Guess the next step would be to either uninstall ITunes or uninstall / reinstall VS, neither options really appeal!

    cheers

    Simon
    Tuesday, March 13, 2007 12:57 PM
  • WOW!  I'm amazed.  Just minutes ago I installed iTunes 7.1.0.59 and now I'm having the same problem with a solution that had been working fine just before the upgrade.  (I'm using VS2005 SP1 Prof Ed on Vista).  Thanks for posting, Simon.  You probably saved me a couple of hours of troubleshooting and frustration.
    Tuesday, March 13, 2007 9:20 PM
  • I'd like to add another "me too". I had no idea why it suddenly stopped working, but I too had just installed iTunes 7.1. Thanks for mentioning it--I never would have thought of that being the problem.
    Wednesday, March 14, 2007 4:25 AM
  • Add me to the list.  Just upgraded iTunes to 7.1.0.59 and got the loaderlock error on a showdialog.
    Wednesday, March 14, 2007 1:39 PM
  • I've posted the following in the VB2005 forum:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1339904&SiteID=1

    No response on that one yet... shame no comment on either from any MS representative on this one yet?

    Nice to know not just me going mad! :-)

    cheers

    Simon

    Wednesday, March 14, 2007 1:46 PM
  • Chalk up another "me too" here.
    Wednesday, March 14, 2007 5:53 PM
  • I am not doing anything with game technologies but my app just started having the same problem. I got to this thread by searching for the "LoaderLock was detected" error message. I too recently updated iTunes. I listen to music while I work and I noticed that before the update iTunes would skip, pause, and jump when doing a compile but after the update the music would play without interruption. This would lead me to believe that they changed something pretty fundemental in the way iTunes works that in turn may be causing this problem.
    Wednesday, March 14, 2007 6:44 PM
  • I retract the statement about iTunes being "all better". It is better than it was before but still breaks up when doing builds.
    Wednesday, March 14, 2007 6:55 PM
  • This happens for me as well, although my application is not a game, nor does it use DirectX. If I try to debug it while running iTunes then I get a LoaderLock MDA, if I close iTunes, it all works fine.

    My iTunes version is 7.1.0.59.

    Hmmm.
    Thursday, March 15, 2007 11:17 AM
  • [locking the thread... this particular forum is for DirectX questions, and general talk about what a loaderlock is, and why you are getting it is better asked in the .Net/VS forums]
    Thursday, March 15, 2007 10:18 PM