调试调用从非托管c托管.NET代码++ [英] Debugging Managed .NET Code Called From Unmanaged C++

查看:177
本文介绍了调试调用从非托管c托管.NET代码++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读SO的解决方案,但到目前为止,没有改正我的问题。我的启动项目是一个非托管C ++项目(我们称之为TestWrapper)。目标是让TestWrapper调用一个托管C ++项目,然后调用我的C#项目。这是工作正常,我没有运行它的问题。

I've read through the solutions available on SO, but nothing so far has corrected my issue. My start-up project is an unmanaged C++ project (We'll call it TestWrapper). The goal is to have the TestWrapper call a managed C++ project that then calls my C# project. This is working fine and I have no issues running it.

但是,我有一个异常,已经发生在我的C#代码。由于某种原因,断点不会被命中,实际的调试中断发生在 ntdll.dll 内。我已经尝试右键单击C#项目并启用非托管调试,但这并不能解决这个问题。如果任何人都能指出我的解决方案,我将非常感激。

However, I have an exception that has been occuring in my C# code. For some reason, the breakpoints do not get hit and the actual debug break occurs inside of ntdll.dll. I have tried right clicking on the C# project and enabling unmanaged debugging but this does not fix the issue. If anyone could point me toward a solution I'd be extremely grateful.

我会继续包括项目布局:

I'm going ahead and include the project layout:

TestWrapper (unmanaged C++) -> ManagedWrapper (managed C++) -> MyCSharpProject (C#)

我有一个感觉,它在调试的配置,

I have a feeling it lies in the configuration of the debugging, but I'm not knowledgeable enough to even know where to begin to look.

推荐答案

调试器必须决定启动是否调试原生,管理或native +托管代码。因此,您必须更改启动项目的调试器设置,而不是您遇到问题的DLL。尝试以下操作

The debugger must decide on startup if it's debugging native, managed or native + managed code. Hence you must change the debugger settings on the start project and not the DLLs where you're having problems. Try the following


  • 右键单击项目并选择属性

  • - >调试

  • 将调试器类型切换为混合

这有点令人误解,调试器设置甚至包括在Visual Studio中的DLL项目中。它对系统没有任何影响。

It's a bit misleading that the debugger settings are even included in DLL projects in Visual Studio. It doesn't have any effect on the system.

这篇关于调试调用从非托管c托管.NET代码++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆