views:

876

answers:

6

I want to debug a piece of code written in C++. The problem is that the dll is mixed - it contains both C++ and CLI (managed C++). The environment is VS 2005.

My entry point is a very simple executable project, written in C++ that just starts the code in the mixed dll.

The problem is that:

  1. if I let the "Debug type" as Auto for both projects, my breakpoints are not hit. (later edit: this is normal, since Auto is based on the contents of executable project).

  2. if I set it to "mixed", the breakpoints are hit but the unmanaged watches are empty. For example, I cannot see the value of an std::string. I can however see basic types like int and bool.

A: 

You sure you enabled all the debugging options? I have seen this happen when 'forgetting' some when trying to navigate the maze of C++ options.

leppie
I cant remember, there are so many, turn max levels for all. Both compiler and linker.
leppie
A: 

I don't have my 2005/2008 environment in front of me, however I seem to recall there is an option that needs to be enabled in the project settings(I believe the debugging tab) in order to do unmanaged debugging. Once this is enabled, you shouldn't have any problems.

A: 

You need to tell Visual Studio to debug more than just your managed code. Go to Tools | Options, select Debugging | General. Uncheck the box next to, "Enable Just My Code (Managed-only)".

LanceSc
+1  A: 

Also, try setting your debugger to Mixed. This will allow debugging of both managed and unmanaged code.

shash
+1  A: 

I can debug in mixed mode in VS2005 by setting the Debugger Type to mixed in the Project Properties (on the Debugging tab). Sometimes these sort of things go away after a nice reboot and a clean rebuild.

If that doesn't work you try attaching to the application after it starts running (Debug | Attach to Process). You can pick the debugging mode by pressing the "Select" button in the middle next to the "Attach to:" section.

Do you have all of the updates from Microsoft? There might be one out there that solves your problem.

In general, mixed mode debugging seems to work much better in VS2008. I recommend upgrading if you can. There is a free version available but I think its limited in some way.

onedozenbagels
A: 

LanceSc's advice really helps. Go to Tools | Options, select Debugging | General. Uncheck the box next to, "Enable Just My Code (Managed-only)" - solves the problem in VS2008

Sergey