如何进入非托管 C++来自我的 C++/CLI 代码的库

发布于 2024-11-27 08:16:20 字数 233 浏览 1 评论 0原文

我的解决方案中有以下三个项目: 1.C#库 2. C++/CLI 托管代码 3. C++ 非托管代码

我确实在我的 C# 项目中选中了“启用非托管代码调试”,并在 Debug/Win32 中构建了两个 C++ 项目。但是,我无法进入非托管代码 - 当我 F11 调用任何非托管方法时,它会向我显示一些随机/错误的代码,然后退出。

因为我的单元测试通过了,所以我知道我的非托管代码确实执行了。

我缺少什么?

I have the following three projects in my solution:
1. C# library
2. C++/CLI managed code
3. C++ unmanaged code

I did check "Enable Unmanaged Code Debugging" in my C# project, and built both C++ projects in Debug/Win32. However, I cannot step into unmanaged code - when I F11 on the call of any unmanaged method, it shows me some random/wrong code then exits.

Because my unit tests pass, I know that my unmanaged code does execute.

What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轮廓§ 2024-12-04 08:16:20

当我遇到这个问题时,它来自以下原因之一:

1)未选中启用非托管代码调试。你已经解决了这个问题。

2) 将 EXE 构建为 x64 或任何 CPU(他们说 x64 可以工作,但事实并非如此)。我想你已经解决了这个问题。

3) 打开“仅我的代码”有时会导致非托管代码调试出现问题(工具、选项、调试器、仅我的代码)

4) C++ 项目设置中的调试选项不正确

5) PDB 文件丢失、损坏或不匹配。您可以通过在调试器中运行时尝试在 C++ 代码中设置断点来检查这一点。如果断点变成空心圆圈,则说明您的调试信息有问题。当您在调试模式下运行时,还要检查输出窗口——它应该告诉您加载了哪些符号。

When I've had this problem it has come from one of these things:

1) Enable unmanaged code debugging not checked. You already fixed this.

2) Built the EXE as x64 or Any CPU (they say x64 works, but it doesn't). I think you already fixed this.

3) "Just my code" being turned on sometimes causes trouble with unmanaged code debugging (Tools, Options, Debugger, Just My Code)

4) Incorrect debug options in the C++ project settings

5) Missing, corrupted or mismatched PDB files. You can check for this by trying to set a breakpoint in your C++ code while running in the debugger. If the breakpoint turns into a hollow circle, something is wrong with your debug info. Also check your output window as you run in debug mode -- it should tell you whose symbols got loaded.

一花一树开 2024-12-04 08:16:20

我经常看到这个问题以“其他”方式出现(即从本机 C++ 到 C++/CLI),这通常是由于调试器没有真正意识到它应该调试本机代码和托管代码。

通常对我来说,在配置属性 -> 设置调试器类型在启动项目中从“自动”调试到“混合”可以解决该问题。

I've seen this issue going the "other" way from time to time (ie, from native C++ to C++/CLI) and it's usually caused by the debugger not really picking up that it's supposed to debug both native and managed code.

Usually for me, setting the Debugger Type in Configuration Properties -> Debugging in your startup project from 'Auto' to 'Mixed' solves the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文