Debugging unmanaged calls from managed app

F

Fredo

I'm using an unmanaged image library (FreeImage). It has a wrapper called
FreeImage.NET which has all the interop stuff for FreeImage.

I have the source for FreeImage and I wanted to trace into the calls, but I
can't figure out how to debug it.

What I did was compiled debug versions of everything (FreeImage,
FreeImage.NET, and my app). I copied the debug exes, DLLs and PDBs for
FreeImage, FreeImage.NET, and my app into a single directory. I then loaded
FreeImage inot VS.NET 2005 and set breakpoints where I wanted them. I went
into the project properties and in the Configuration Properties/Debugging, I
set Command to be my test app. Then I hit F5.

I can set breakpoints in the managed code, no problem (even though the
project I'm running from is unmanaged C++). When I try to set breakpoints in
the unmanaged code, it puts the little hollow red circle on the line with a
tooltip saying, "The breakpoing will not currently be hit. No symbols have
been loaded for this document"

In fact, while my app and FreeImage.NET show up as being loaded in the Debug
Output, the FreeImaged.dll (debug version of the unmanaged freeimage DLL)
never seems to appear get loaded, but it clearly is because I'm making calls
into it and they're working.

So how can I debug the unmanaged code?

Thanks.
 
F

Fredo

I figured it out.

One problem was I forgot I had a copy of the release build of the
freeimage.dll in my \Windows\System32 directory and that was the one being
loaded.

I also figured out that I had to set the debugger to mixed mode debugging.
Now it works. Sweet.
 
P

Pinki

You have to set the debugger option in the project setting to "Both". In
your C++ project click on properties and go to debugger setting. It is set
to auto by default which means it will just debug unmanged code. If you set
it to managed, it should stop at the breakpoint.

Paul
 

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