Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem debugging C++ code from .NET application

I have .NET service (C#) that uses a couple of c++ libraries. I have a desperate need to get into C++ methods but when I set the breakpoints they get disabled in the run time.

Where to look at?

I set "Attach Debugger" in C++ project settings but this does not seem to change a bit.

Please advice. Where to look at?

The libraries are quickfix engine if anyone cares.

like image 354
Captain Comic Avatar asked Jun 29 '11 11:06

Captain Comic


2 Answers

You need to enable unmanaged code debugging for your project. To do this:

  1. Right-click on your project in the Solution Explorer, and click "Properties".
  2. In the "Debug" tab, check the box labeled "Enable unmanaged code debugging".

   

By default, a project targeting the .NET Framework will only debug managed code. You have to tell it explicitly that you want to debug unmanaged code.

If that doesn't fix the problem, also make sure that the "Enable Just My Code" setting is not turned on in the debug settings found in the Options dialog.


Does not work when i attach to process. Only works when i run from the studio

Correct. When you attach to a process, your project isn't [necessarily] loaded, and Visual Studio doesn't pay any attention to its settings.

In this situation, you need to set the appropriate options in the "Attach to Process" dialog. To do so:

  1. Click the "Select..." button at the end of the line labeled "Attach to:".
  2. In the dialog that appears, make sure that "Native" is checked, in addition to the appropriate version of "Managed" code.

     

like image 165
Cody Gray Avatar answered Sep 25 '22 02:09

Cody Gray


Go to Project Properties -> Debug -> and set the checkbox

Enable unmanaged code debugging

HTH

like image 45
Armen Tsirunyan Avatar answered Sep 24 '22 02:09

Armen Tsirunyan