Jump to content

  • Log In with Google      Sign In   
  • Create Account


[.net] .NET 2.0 "OS Loader Lock" exception


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 BeanDog   Members   -  Reputation: 1063

Like
0Likes
Like

Posted 07 December 2005 - 01:19 PM

I have a class library that I use in my main application. Under .NET 1.1, it worked great. Under 2.0, I get a new exception: LoaderLock was detected Message: DLL 'D:\My Documents\Visual Studio 2005\Projects\SVS_Client\bin\Debug\SQLiteNET.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. Ooookay. What is this? How do I know when is an appropriate time to begin executing code from the assembly? SQLiteNET.dll does call non-managed code, maybe that has something to do with it. So much for breakless upgrading :-p ~BenDilts( void );

Sponsor:

#2 rfterdarc   Members   -  Reputation: 139

Like
0Likes
Like

Posted 07 December 2005 - 01:24 PM

in the menu try: Debug -> Exceptions..., and disable something in there

#3 BeanDog   Members   -  Reputation: 1063

Like
0Likes
Like

Posted 07 December 2005 - 03:37 PM

They weren't kidding with that message, though--the program hangs.

#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 07 December 2005 - 09:44 PM

http://www.thezbuffer.com/articles/304.aspx

#5 Shinkage   Members   -  Reputation: 595

Like
0Likes
Like

Posted 10 December 2005 - 10:58 AM

Essentially, the current version of DirectX doesn't play well with the current version of Visual Studio. It's a known issue and should be resolved in the next update to the DirectX library (not sure where I read this, but it was somewhere on Microsoft's site).

Right now you're just going to have to disable that exception from being thrown. Hit the Debug->Exceptions... menu item, open up the open up the "Managed Debugging Assistant" item, and uncheck the box next to the "LoaderLock" item. IIRC you should be fine in most situations as long as you avoid calling stuff from your DllMain function.

#6 Arild Fines   Members   -  Reputation: 968

Like
0Likes
Like

Posted 10 December 2005 - 11:33 AM

It's not an "exception" per se. The Managed Debugging Assistants are a set of probes looking for common errors in .NET applications. Running code inside the OS loader lock is one of them. All DLLs created in Managed C++ with the VC2002 compiler would have this problem. VC2003 gave you a way to avoid it, but it was pretty tricky and few bothered, especially since the problem very rarely manifests itself.

#7 Mrs Kensington   Members   -  Reputation: 421

Like
0Likes
Like

Posted 13 December 2005 - 04:52 AM

This should be fixed now as the December 2005 DirectX SDK has been released with non-beta 2.0 versions of Managed DirectX.

See here for more info.

#8 Arild Fines   Members   -  Reputation: 968

Like
0Likes
Like

Posted 13 December 2005 - 05:14 AM

Quote:
Original post by Mrs Kensington
This should be fixed now as the December 2005 DirectX SDK has been released with non-beta 2.0 versions of Managed DirectX.

I'm not sure what Managed DirectX has to do with this:

Message: DLL 'D:\My Documents\Visual Studio 2005\Projects\SVS_Client\bin\Debug\SQLiteNET.dll' is attempting managed execution inside OS Loader lock


#9 Shinkage   Members   -  Reputation: 595

Like
0Likes
Like

Posted 13 December 2005 - 07:09 AM

Woops. I've gotten so accustomed to seeing this message in this context coming from the managed directx runtime my brain just kinda skipped over the DLL file it was coming from. Looks like SQLiteNet needs to be updated for .NET 2.0 as well.

#10 Krisc   Members   -  Reputation: 494

Like
0Likes
Like

Posted 13 December 2005 - 09:42 PM

I got the error when trying to create an instance and initialize a Device inside a constructor. Perhaps that is your problem, even though it has nothing to do with DirectX?

#11 Arild Fines   Members   -  Reputation: 968

Like
0Likes
Like

Posted 14 December 2005 - 04:53 AM

Quote:
Original post by Krisc
I got the error when trying to create an instance and initialize a Device inside a constructor. Perhaps that is your problem, even though it has nothing to do with DirectX?

No. The issue here is that SQLiteNet.dll is a mixed-mode (contains both managed and unmanaged code) DLL compiled with either Visual Studio 2002 or 2003. All 2002-compiled DLLs will have this problem as well as most 2003 DLLs. The only way to deal with it is to turn off the warning.



#12 vidalsasoon   Members   -  Reputation: 100

Like
0Likes
Like

Posted 17 December 2005 - 12:26 PM

I also had this problem today. I fixed it with help from this article:

http://msdn2.microsoft.com/en-us/library/ms173267.aspx


...but I had the source file to recompile.

#13 DmGoober   Members   -  Reputation: 136

Like
0Likes
Like

Posted 20 August 2006 - 05:15 PM

This worked for me:
1) Remove the references to the assemblies that are LoaderLocking. (I recommend writing down the path to the assembly so you don't forget it.)
2) Rebuild. The build will fail.
3) Add back the references to the assemblies you just removed.
4) Rebuild and re-run.

Alexander




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS