Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to debug a project with a C# assembly and a C++/Cli assembly.

An interface defined in C# is inherited by a C++/Cli class, which in turn calls a native C++ class. Mixed-mode debugging is enabled in both C++ and C# assembly, as well as the startup .exe.

Now, when I try to debug into the C++ part, it gets tricky; if I simply set breakpoints in the C++ part, they are not hit (despite the fact that I know that they are hit because logs (etc) are written and throwing an exception there actually will throw it properly).

When I set a breakpoint at the latest call in C# before the call to the mixed-mode assembly, I can step into the C++/Cli code, and even into the native part. However, the Call stack is shown as

MyMixedMode.dll!<Unknown function> Line ... 

and I cannot inspect any locals (the locals view is just empty while inside the native code).

Any ideas what I might be doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
127 views
Welcome To Ask or Share your Answers For Others

1 Answer

Unfortunately pieces of the tooling support in VS for C++/CLI projects keep falling off, they are struggling to keep it maintained. There's an issue with the new debug engine added to VS2012, the one that supports the new C++ debugging visualizers, it doesn't support C++/CLI anymore.

VS2012 Update 1 added a new setting in Tools + Options, Debugging, General, named "Managed C++ Compatibility Mode". Confusingly renamed to "Use Managed Compatibility Mode" in VS2013. Undocumented in the MSDN page for this settings page. What it does is force the debugger to use the old debugging engine instead of the new one.

This does have a side-effect, those shiny new debugging visualizers won't work when you have the option turned on. Keep this in mind if the debug info for your native code doesn't look right.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...