Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging unmanaged code while debugging managed code

Tags:

The .NET 3.5 application I am working on consists of bunch of different solutions. Some of these solutions consist of managed code(C#) and others have unmanaged code(C++). Methods written in C# communicate with the ones written in C++. I am trying to trace the dependencies between these various functions and I thought setting breakpoints on the solution consisting my C++ functions. One of the C# solutions have the startup project. I run this solution in debug mode with the expectation that the breakpoints in my unmanaged code will be hit but nothing really happens. Can somebody guide me through the process of debugging mixed applications such as these using the Visual Studio IDE?

Thanks

like image 885
sc_ray Avatar asked Mar 25 '10 21:03

sc_ray


People also ask

What is managed debugging?

Managed debugging assistants (MDAs) are debugging aids that work with the common language runtime (CLR) to provide information on runtime state. The assistants generate informational messages about runtime events that you cannot otherwise trap.

How do I Debug managed code in Visual Studio?

For Visual Basic, select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes. Select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes.

Can you edit code while debugging in Visual Studio?

With Edit and Continue for C#, you can make changes to your code in break mode while debugging. The changes can be applied without having to stop and restart the debugging session.

How do I skip the code while debugging in Visual Studio?

You can also click on the line you want to skip to and hit Ctrl+F10 (Run to Cursor).


2 Answers

By default a managed project will only start the debugger with managed debugging enabled. It doesn't consider that there are unmanaged projects in the same solution. In order to debug both you need to explicitly enable unmanaged code debugging.

  • Right Click on the project and select properties
  • Go to the Debug tab
  • Check "Enable Unmanaged code debugging"
like image 165
JaredPar Avatar answered Sep 28 '22 02:09

JaredPar


  1. Go to the Managed project property.
  2. Right click on it and go to the debug tab.
  3. There is a section called enable debugger under that section.
  4. Check the "Enable native code debugging" option

then you will be able to debug the native code. Good luck !!!

Please refer the below attached image highlighted with red rectangle.

enter image description here

like image 24
Jnana Avatar answered Sep 28 '22 03:09

Jnana