Loader lock error message

C

Claudia Fong

In my windows form I have a comboBox and a textBox. When I try to write
something in the

textBox it shows me the error message below:

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.

can someone tell me how to avoid this or why is this happenning?

Cheers!

Claudi
 
P

Peter Duniho

In my windows form I have a comboBox and a textBox. When I try to write
something in the

textBox it shows me the error message below:

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.

can someone tell me how to avoid this or why is this happenning?

I'm not entirely clear on all of the scenarios in which this happens.
Clearly you have something going on besides having a simple form with just
a ComboBox and a TextBox. The MDA exception you're seeing is .NET trying
to detect when you try to call managed code from within some DLL
initialization code. This _could_ deadlock if the managed code in turn
needs to load a DLL.

The only time I've run into it was when I use the
DirectX.AudioVideoPlayback class; it reliably sets this off. As near as I
can tell, the warning is benign.

You can turn the warning off in the Debug/Exceptions... menu under the
Managed Debugging Assistants section. Of course, if you have a real
problem then you could wind up not having it get caught and running into a
deadlock problem later. But I would say that generally speaking, unless
you have some sort of conditional initialization in the DLL that's being
loaded that sometimes could cause another DLL to be loaded and sometimes
might not, then if you really have a problem you'll find out right away
and don't need the MDA to tell you about it.

Of course, if you are not the owner of the code implementing the DLL in
the first place, then there's not much you can do about it. You can
either hope that the DLL author, even though they are executing managed
code, has ensured that doing so won't cause another DLL to be loaded, or
you can avoid using the DLL. Other than that, I'm not sure there's much
else you can do.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top