LoaderLock was detected

Add-in Express™ Support Service
That's what is more important than anything else

LoaderLock was detected
 
David Zou


Guest


Hi,

I'm using the C# Application to call a COM in VS 2005 and when I close my application I get an MDA error saying
something about a LoaderLock. I think it's caused by passing a object ref into the COM to callback.
Any idea how to make this go away?

Here's the exact message:

LoaderLock was detected
Message: 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 get the same result if I just create a simple application with a Form and
the control embedded in it.

Thanks!
Posted 12 Dec, 2005 20:02:51 Top
Brad Smith




Posts: 49
Joined: 2005-11-22
Interesting, I get those too, but I get two in a row. Are you using a Shim by any chance?

I'm not 100% sure if this is an actual "problem", or whether the MDA stuff in VS.NET 2005 is a bit over-sensitive and perhaps reporting a bogus error. I've found that when I just hit Continue there are no apparent ill effects. And when I run the add-in outside the debugger, I don't see any indications of memory leaks or hangs or crashes.

Which Office app are you running against? In my case it's Outlook. The more clues we can provide to Sergey, the easier (hopefully) it'll be for him to pin it down.

Brad.
Posted 13 Dec, 2005 10:41:06 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi David.

Do you use the Marshal.ReleaseComObject method to clear COM objects?
Posted 13 Dec, 2005 10:46:30 Top
Zou David


Guest


I think Sergey is right. I don't use the Marshal.ReleaseComObject method to clear COM objects. And I will add this statement to my program. I hope the problem will be solved.
Thanks for all your advice.
Posted 13 Dec, 2005 19:30:07 Top
Brad Smith




Posts: 49
Joined: 2005-11-22
Can you let me know? I do use ReleaseComObject, but I use a fair number of objects and while I *think* I have them all Released, if you manage to eliminate the LoaderLock error then it implies I need to dig a little deeper to find the one(s) I missed.

Brad.
Posted 14 Dec, 2005 10:53:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi Brad.

Could you please send me your project? I will test it.
Posted 14 Dec, 2005 17:40:35 Top