Stepping into vc++ dll from c#

G

Guest

I need to debug a native vc++ dll used in a c# app winforms app. The c# app
employs DllImportAttribute, and static extern int, to define the functions it
calls from the vc++ dll.
The vc++ dll is not referenced, nor does it use com to communicate, rather
it registers the windows handle with the dll and uses a WndProc override to
receive windows messages from the event.

I tried building the dll in full debug, and dropping it into the c' apps
debug directory in order to step into the dll's methods, but unfortunately I
got the following 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.

Can anyone provide any help as to what I need to do in order to step from
the c# app into the vc++ dll's functions.

Thanks.
 
B

Ben Voigt [C++ MVP]

mk said:
I need to debug a native vc++ dll used in a c# app winforms app. The c#
app
employs DllImportAttribute, and static extern int, to define the functions
it
calls from the vc++ dll.
The vc++ dll is not referenced, nor does it use com to communicate, rather
it registers the windows handle with the dll and uses a WndProc override
to
receive windows messages from the event.

I tried building the dll in full debug, and dropping it into the c' apps
debug directory in order to step into the dll's methods, but unfortunately
I
got the following 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.

Did you make the C++ dll?

Is it possible that it isn't really a native dll, but uses .NET? Use
dependency walker to check, you'll see the .net runtime engine (clr,
mscoree) imported if it uses .net inside.
Can anyone provide any help as to what I need to do in order to step from
the c# app into the vc++ dll's functions.

Enable unmanaged debugging on the Debug tab of your main .exe project.
 
G

Guest

Hi,
Thanks for the quick response. It is actually a native dll, written by
another team at work, no clr aspects whatsoever. Its turned out, however,
that I was able to trace the error to an input given to the vc++ dll, and
thankfully don't need to hack the debugging.


Kind regards,

mk
 

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