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)"
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
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
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).
Had faced the same issue and did all that was suggested in the accepted answer but the breakpoints in the unmanaged DLL was not getting hit!
However, when i did the following i could finally debug the DLL!
Select solution in Solution Explorer
Select from Menu
>>Tools
>>options
>>Debugging
>>General
Uncheck "Require source files to exactly match the original version"