调试 VC++ 6 从 C# 调用 DLL
我有一个用 Visual Studio 6 编写的旧 DLL,我从用 Visual Studio 2010 编写的 C# 调用它。该 DLL 无法正常工作,我想对其进行调试。我该怎么做?我有源代码项目,但不知道如何进入它。
注意:当我说“不起作用”时,对 DLL 的调用会成功,并且在失败之前会稍微浏览一下 DLL 中的代码,但我想准确地追踪到哪里。
I have an old DLL written in Visual Studio 6 which I am calling from C# written in Visual Studio 2010. The DLL is not working properly and I want to debug into it. How can I do this? I have the source code project but cannot see how I can step into it.
Note: When I say "doesn't work", the call to the DLL succeeds and it gets a little way through the code in the DLL before failing, but I want to track down exactly where.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MSDN 上此处描述了调试 DLL 的技术。您需要从 Visual Studio 6(即开发 DLL 的工具)中执行此操作,因此术语将发生变化。但原则是一样的。
The technique of debugging a DLL is described here on MSDN. You'll need to do this from Visual Studio 6 (i.e. the tool that developed the DLL) and so the terminology will have changed. But the principles remain the same.
只要您拥有带有相应二进制文件和源代码的 PDB 文件,就可以在 .NET 进程上附加 VS6 调试器。但是,您只能中断 DLL 代码。
如果选中“允许非托管调试”标志,则附加另一个 VS+ 应该可以工作,但调试器可能不会加载符号。重新编译 DLL 将解决最后一个问题。
Attaching VS6 debugger on the .NET process shall work, as long you have the PDB file with the corresponding binary and the sources. You can break only on DLL code, however.
Attaching another VS+ shall work if the flag "Allow unmanaged debugging" is checked, but there is a possibility that symbols are not loaded by the debugger. A recompilation of the DLL shall solve the last problem.
打开Visual C++ Dll项目,在需要的地方设置断点。在“项目属性”、“调试”、“调试会话的可执行文件”中,键入使用此 Dll 的 .NET 可执行文件。开始调试 (Go)。当调用 VC++ 函数时,调试器会中断。使用这种方式,您只能调试非托管 VC++ 代码。
另一种方法是从 .NET 客户端以混合调试模式开始调试。将 VC++ 项目添加到解决方案并重建它以调试托管和非托管代码。
Open Visual C++ Dll project, set breakpoint where you need. In the Project properties, Debug, Executable for debug session, type .NET executable file which uses this Dll. Start debugging (Go). When VC++ function is called, debugger breaks. Using this way, you can debug only unmanaged VC++ code.
Another way is to start debugging from .NET client in mixed debugging mode. Add VC++ project to the solution and rebuild it to debug both managed and unmanaged code.