Cannot Debug Unmanaged Dll from C#

这一生的挚爱 提交于 2019-12-02 16:38:09

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"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!