调试com可见的dll托管代码
我编写了一个 COM 可见的 dll,它将从本机 Win32 程序中调用。出于调试目的,我向包含 dll 的解决方案添加了一个简单的 WinForms 客户端。
现在,当我在 dll 中设置断点时,会命中断点,但我无法单步执行代码:调试器总是跳转到 dll 中的下一个断点,或者在调用后客户端中的第一行代码DLL。
如何让调试器单步执行 dll 代码?
我认为这可能是“仅启用我的代码”选项,但未设置。
更新 jdv 建议在项目属性中设置“启用非托管代码调试”,但这并没有达到预期的效果。
谢谢,米尔。
I have written a COM visible dll, which will be called from a native Win32 program. For debugging purposes I added a simple WinForms client to the solution containing the dll.
Now when I set a breakpoint in the dll, that breakpoint is hit, but I can't step through the code: the debugger always jumps to the next breakpoint in the dll, or the first line of code in the client after the call to the dll.
How can I get the debugger to step through the dll code?
I thought it might be the "Enable Just My Code" option, but that is not set.
Update
jdv suggested setting "enable unmanaged code debugging" in the project properties, but that didn't have the desired effect.
Thanks, Miel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是我执行的步骤,这些步骤使我能够成功调试作为 COM 组件公开的 .NET 程序集:
首先创建一个类库,其中包含将作为 COM 对象公开的类
: microsoft.com/en-us/library/ms247123.aspx" rel="nofollow noreferrer">使用强密钥签署程序集并注册为 COM 对象:
注册 COM 对象后,您可以创建一个新控制台在新的 Visual Studio 实例中运行应用程序来测试 COM 对象:
在
InvokeMember
行上放置一个断点并运行该应用程序。一旦断点被击中,打开 模块窗口 (Ctrl +DM)并确保为 COM 程序集加载了符号:现在,如果您按F11 可以单步进入COM类进行调试。
备注:您也可以直接打开包含
Foo
类的 .cs 文件并直接在其中放置断点。再次重要的是为程序集加载符号,或者当您放置断点时,Visual Studio 会告诉您不会命中该断点。Here are the steps I performed and which allowed me to successfully debug a .NET assembly exposed as COM component:
Start by creating a class library containing a class that will be exposed as COM object:
Sign the assembly with a strong key and register as COM object:
Once the COM object is registered you may create a new console application in a new Visual Studio instance to test the COM object:
Place a breakpoint on the
InvokeMember
line and run the application. Once the breakpoint is hit open the Modules Window (Ctrl+D M) and make sure that symbols are loaded for the COM assembly:Now if if you press F11 you can step into the COM class to debug.
Remark: You can also directly open the .cs file containing the
Foo
class and directly place a breakpoint there. Once again the important thing is to have the symbols loaded for the assembly or when you place your breakpoint Visual Studio will tell you that this breakpoint won't be hit.VS2008 SP1 之后发布了一个修补程序,解决了许多调试问题。知识库文章在这里,修补程序下载此处。
There was a post VS2008 SP1 hotfix released that solves a number of debugging problems. The KB article is here, the hotfix download is here.