C# newbie trying to debug AutoCAD API-function

C

c-sharp newbie!

Dear all,

I'm a C# newbie, trying to debug AutoCAD API-function. I get this
message in Microsoft Visual Studio:

----------------------------
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.
----------------------------

And I cannot debug the code. I tried to google what this means, but I
don't understand it at all! What does this mean?

Thanks.
 
C

c-sharp newbie!

Hi Pete,
The real question is something you'll have to take up with AutoCAD and
however you're using their API.

But there are so many google hints, that I don't think this error
message only applies to AutoCAD dll:

http://www.google.dk/search?q=+Atte...s=org.mozilla:en-GB:official&client=firefox-a
But, I can tell you what the exception is saying and why. You've somehow
gotten into a situation where some managed code is being executed while a
DLL is being initialized (presumably the AutoCAD DLL). Without full

Okay, but I come from C/C++ and am not at all used to managed code.
The only thing I know about this is: "Managed code is computer program
code that executes under the management of a virtual machine, unlike
unmanaged code, which is executed directly by the computer's CPU",
which I found from google and other places.

You said some managed code is being executed while a DLL is being
initialized. Since google doesn't indicate this is a Autocad problem,
is it possible to first initialize the DLL and then execute the
managed code somehow? I don't understand a word of that error message.
details on your code and how the AutoCAD stuff works, it's not possible to
be more specific than that. But the risk is that managed code may itself
try to do something that would require the OS loader lock, causing
deadlock if that lock has already been acquired by something else (it's
not re-entrant).

Let's forget all about AutoCAD and say it's just an arbitrary DLL
file, which google also indicates it easily could have been. What do
you mean by:

1) "But the risk is that managed code may itself try to do something
that would require the OS loader lock, " ???

2) "causing deadlock" - what is a deadlock and why should this happen?

3) "if that lock has already been acquired by something else" - how
should that lock has been acquired by something else?

4) What do you mean by: "it's not re-entrant"?


As you can see, I'm completely lost. In general terms, I asked the
question here because perhaps I could learn to understand the message
and I'm completely sure the issue is not (at least) 100% AutoCAD-
related. I'm completely sure it could happen to any dll (see google if
in doubt).
I know of at least one example of Microsoft-provided code where this MDI

I am also very much a windows-programmer newbie, so what is MDI ?
exception occurs in a benign way (the DirectX AudioVideoPlayback stuff),

I'm sure you're right, but how does this exception happen in a benign
way?
and it's possible that the error is benign in this case as well. You can

I hope so :)
either work with AutoCAD to determine exactly how you got into the
situation and figure out how risky it is, or you can just test it to make
sure it works in your expected scenarios and hope your users don't figure
out a way to break it. :)

I works without debugging (release mode), but when I try to debug the
code it doesn't work at all and the exception keeps popping up. AFAIR:
The breakpoint is not a full red circle as it is normally, but it was
a white circle with a tiny red border to indicate that I tried to put
a breakpoint there but the debugger failed to debug for some reason...
 

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