Papa John
Papa John

Reputation: 3794

Debugging C++ project in Visual Studio 2010

I wrote a C# project in which I use a C++ dll (also written by me). I am trying to debug this dll function from my C# solution.

I have added C++ project to C# solution and manage its output - that's ok. But I could not get into the dll functions (break points not loaded).

Upvotes: 1

Views: 2530

Answers (3)

kmort
kmort

Reputation: 2948

Samuel Slade's answer is correct with one clarification:

I was trying to debug into an ATL/MFC C++ COM object from some C# code using Visual Studio 2010. I had a separate Solution for each project and could not make it work. When I put both projects into one Solution and enabled unmanaged code debugging as directed above, it worked wonderfully.

So cram both projects into one Solution and it should work.

Upvotes: 0

Derrick Turk
Derrick Turk

Reputation: 4336

You will want to make sure that your native DLL was compiled and linked in debug mode. Though I don't work with the Visual Studio IDE much, the command line options you want are /Zi for cl.exe and /DEBUG for link.exe. This should result in the DLL being built with debug symbols enabled, and a .pdb file being generated. You should then be able to attach to the process as usual (you may have to do this from the Visual C++ debugger---again, I don't work much with the IDE) and set breakpoints on functions in the DLL.

Upvotes: 1

Samuel Slade
Samuel Slade

Reputation: 8623

Assuming you are using a version of Visual Studio that is not Express, you should be able to allow native C++ debugging by checking an option in the properties pane of the project you are running. Go to Project Properties -> Debug -> Enable unmanaged code debugging.

enter image description here

Upvotes: 2

Related Questions