views:

929

answers:

5

I have a DLL that was written in C++ and called from a C# application. The DLL is unmanaged code. If I copy the DLL and its .pdb files with a post build event to the C# app's debug execution dir I still can't hit any break points I put into the DLL code. The break point has a message attached to it saying that "no symbols have been loaded for this document".

What else do I have to do to get the debugging in the dll source?

I have "Tools->Options->Debugging->General->Enable only my code" Disabled. The DLL is being compiled with "Runtime tracking and disable optimizations (/ASSEMBLYDEBUG)" and Generate Debug Info to "Yes (/DEBUG)"

+1  A: 

You need to enable unmanaged (Native) debugging.

If you are attaching to the process after it is started:

Go to the Tools menu, and then attach to process, make sure you have native debugging enabled.

You will see a read only edit box:

Attach to: Managed code, Native code [Select]

Make sure Native code is listed there. If not add it.

If you are starting your project from within visual studio:

On your project properties that you are starting in debug mode. Go to the project Properties, and then select the debug tab.

Make sure this checkbox is checked on:

Enable unmanaged code debugging

Brian R. Bondy
+1  A: 

When you attach to a process to debug, you have to specify how you want to attach. You have a few options, namely Managed, and Native. In order to debug C# code with unmanaged C++, you have to attach to a process as Managed and as Native (both can be selected at the same time).

Joseph
+9  A: 

To debug into your C++ DLL you need to enable mixed mode debugging on the startup application in your solution.

  • Right click on project -> Properties
  • Go to Debug Tab
  • Check "Enable unmanaged code debugging"

This will allow you to debug into native code for an F5 style scenario. If you want to enable it for attaching to the process then do the following in the "Attach to Process" Dialog

  • Select the process to debug
  • Click on the "Select ..." button above the process list
  • Click "Debug these code types"
  • Check both Managed and Native
JaredPar
While I was going to answer this, I wasn't sure if it was so simple or not. If it is this simple, I've likely always misused it while attempting to debug managed C++ code that interfaces with native code.
Will Eddins
A: 

Just wanted to thank the users of this thread. I have been struggling with getting a managed VB.Net project to step into an unmanaged Fortran dll. This thread didn't exactly reveal anything new that I hadn't googled, but it was essentially the exact task I needed to do. I was able to start fresh from VS2008, create a Fortran DLL project, create a VB.Net Console App, and step from VB to Fortran with no problem. Thanks for the clarity and having it all in one simple thread!

A: 

Thanks to everyone at this forum This really came in handy!