How to debug and enter a native code project from within a .NET C # project?

I am developing a .NET core application (.NET Standard 1.6) in VS2015. An application calls C ++ code through P / Invoke. Now I need to switch to the C / C ++ code of my native dll project.

In a regular .NET application, allowing uncontrolled debugging of the code in the application properties window, we can directly enter the C / C ++ code:

step into the C / C ++ code

But I can not find such an option in the .NET .NET project. And I know that I can attach a debugger to the application to debug only my own code, but this is not suitable for my case.

Again, I want to debug from managed C # code to native C / C ++ code.

Any ideas?

Maybe I should go back to the .NET Framework so that I can debug my own code. It is very difficult to debug printf . printf

+5
source share
1 answer

UPDATE
Perhaps this function has already been implemented, see this .


Just as @cynic said, this is not yet supported ( 2016-11-1 ).

This can be verified using the following steps provided by cynic.

  • Pause in your program (for example, calling Console.ReadKey).
  • Joining the dotnet.exe process by selecting "Managed (CoreCLR)" and "Native" code types
  • You will receive a message box saying "Interop debugging is not supported."

Not supported.

Here is the right way to debug your native DLL.

  • Right click on solution, add existing project
  • Open 'dotnet.exe'. This is usually set to "C: \ Program Files \ dotnet \ dotnet.exe".
  • Now you will see another node in the solution explorer for dotnet.exe. Right click to open project properties:
  • Change the working directory to what you want.
  • Change the arguments as the path to your inline dll
  • Change exe project to your startup project

RECOMMENDED: go to Tools-> Options-> Projects and Solutions-> Build and Run, uncheck "Only create launch projects and Run dependencies"

+1
source

Source: https://habr.com/ru/post/1259080/


All Articles