从托管调用时调试本机代码
我编写了一个 C# 应用程序,其中大部分工作是在 C++ 后端完成的。现在我一直在积极开发双方,后端的当前迭代在特定函数中引发了访问冲突。我该如何去调试这个? VS 不会因本机代码中的异常或断点而中断,也不会显示本机代码的调用堆栈或局部变量,即使两个项目都是在同一解决方案中构建的。我宁愿避免返回并用日志语句乱扔我的所有本机代码。
I've written a C# application, where much of the work is done in a C++ back-end. Now I've been actively developing both sides, and the current iteration of the back end throws an access violation in a specific function. How can I go and debug this? VS won't break on exceptions or breakpoints in native code, nor show the call stack or locals of the native code, even though both projects are built in the same solution. I'd rather avoid having to go back and litter all my native code with logging statements.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您打开混合模式调试(并重新编译项目),VS 也会调试本机代码。
请参阅微软的解释: http://msdn.microsoft.com/en-us/库/kbaht4dh.aspx
VS will debug the native code, too, if you switch on mixed-mode debugging (and recompile your project).
See the Microsoft's explanation: http://msdn.microsoft.com/en-us/library/kbaht4dh.aspx
来自 Visual Studio 2016
From Visual Studio 2016
使用 Visual Studio 您可以将调试器从本机 C++ 项目附加到正在运行的 C# 应用程序。
在附加调试器并运行 C# 应用程序之前
Using Visual Studio you can attach the debugger from your native C++ project to your running C# application.
Before attaching the debugger and running your C# application