Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Debugging unmanaged calls from managed app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fredo - 02 Mar 2008 17:52 GMT
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.
Fredo - 02 Mar 2008 19:24 GMT
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.

> I'm using an unmanaged image library (FreeImage). It has a wrapper called
> FreeImage.NET which has all the interop stuff for FreeImage.
[quoted text clipped - 23 lines]
>
> Thanks.
Pinki - 02 Mar 2008 19:33 GMT
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

> I'm using an unmanaged image library (FreeImage). It has a wrapper called
> FreeImage.NET which has all the interop stuff for FreeImage.
[quoted text clipped - 23 lines]
>
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.