Debugging in managed / unmanaged dlls doesn't work in VS 2005. Why?
I want to debug a piece of code written in C ++. The problem is the dlls are mixed - it contains both C ++ and CLI (managed C ++). Environment - VS 2005.
My entry point is a very simple executable project written in C ++ that only runs code in a mixed dll.
The problem is that:
-
if I allow "Debug Type" as "Auto" for both projects my breakpoints are not hit. (edit later: this is ok as Auto is based on the contents of the executable project).
-
if I set it to "mixed" the breakpoints are removed but the unmanaged clock is empty. For example, I can't see the value of std :: string. However, I can see basic types like int and bool.
I can debug in Mixed Mode in VS2005 by setting the Debugger Type to Mix in the project properties (under the Debug tab). Sometimes things like this go away after a good reboot and clean recovery.
If that doesn't work, try connecting to the app after it starts (Debug | Attach to Process). You can select a debug mode by clicking the "Select" button in the middle next to the "Attach to:" section.
Do you have all the updates from Microsoft? There might be one that solves your problem.
Overall, mixed mode debugging seems to work much better in VS2008. I recommend updating if possible. There is a free version, but I think it is limited in some way.
Also try setting your debugger to Mixed. This will allow you to debug both managed and unmanaged code.
Are you sure you have enabled all the debugging options? I saw this when I "forgot" some when trying to navigate the maze of C ++ options.
I don't have my 2005/2008 environment in front of me, but I seem to remember that there is an option that needs to be enabled in the project settings (debug tab, I believe) in order to perform unmanaged debugging. Once this is enabled, you shouldn't have any problems.
You need to tell Visual Studio to debug more than just your managed code. Go to the Tools | Options, select Debug | General. Uncheck the box next to Include My Code Only (Managed Only).
LanceSc's recommendations really help.
Go to the Tools | Options, select Debug | General Provisions.
Uncheck "Include only my code (managed only)"
This resolves the issue in VS2008.