调试C ++ / CLI:<未知功能>没有本地人本地人、功能、CLI、lt

2023-09-02 21:12:38 作者:大爷犯二i

我想用C#组件和C ++ / CLI组件的调试项目。

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

在C#中定义的接口由C ++ / CLI类,后者又调用本地C ++类继承。混合模式调试在C ++和C#程序集,以及启动.exe文件启用。

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.

现在,当我尝试调试到C ++的一部分,它变得非常棘手;如果我简单地设置在C ++部分断点,他们不打(尽管我知道他们的打击,因为日志(等)写入,并抛出一个异常,这里居然将正确地把它)。

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).

当我在调用混合模式的组装前的最近通话在C#中设置断点,我可以步入C ++ / CLI code,甚至到本机的一部分。但是,调用堆栈被示为

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 ... 

和我不能检查任何当地人(当地人查看就是一句,而里面的本土code)。

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?

推荐答案

不幸的是在VS的工具支持C ++ / CLI项目的部分不断脱落,他们正努力保持它的维护。这里有一个问题,加到VS2012新的调试引擎,支持新的一个C ++调试展示台的,它不支持C ++ / CLI了。

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更新1添加了一个新的设置在工具+选项,调试,一般,命名为托管C ++兼容模式。令人困惑的是重命名为VS2013使用管理的兼容模式。无证在MSDN页面此设置页面。它的作用是迫使调试器使用的新的旧的调试引擎来代替。

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.

这确实有副作用,当你可以选择开启那些闪闪发光的新的调试可视化工具将无法正常工作。请记住这一点,如果你的母语code中的调试信息不​​正确。

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.