如何调试 COM C++ 进程外服务器?(客户:Excel vba) [英] How to debug a COM C++ Out of Process Server ? (client: Excel vba)

查看:27
本文介绍了如何调试 COM C++ 进程外服务器?(客户:Excel vba)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何使用 Visual Studio 2015 调试 COM ATL C++ 进程外 exe 服务器.

I don't know how to debug a COM ATL C++ out of process exe server with Visual Studio 2015.

对于COM ATL DLL没有问题,当我调用COM dll时会自动触发断点.但是,当我尝试调试 EXE 服务器时,调试器没有中断.实际上exe服务器只是按需加载,客户端启动时不会加载exe服务器的调试符号.

For a COM ATL DLL there is no problem, the breakpoints are automatically triggered when I call the COM dll. However when I try to debug an EXE server, the debugger didn't break. Indeed the exe server is only loaded at demand and the debug symbols of the exe server are not loaded when the client starts.

我的调用 COM 服务器的客户端是 Excel VBA(我通过工具/参考在 VBA 编辑器中添加了对 com exe 的引用).为了调试它,我在 Visual Studio Debug 命令中设置了 Excel.exe 的路径,并将我的 xlsm 文件的路径设置为参数.然后我只是在 Excel 中调用调用 VBA 代码.它适用于 com DLL 但不适用于 COM Exe.我还尝试将 VS 附加到 Excel,但没有奏效.

My client, that call the COM server, is Excel VBA (I have added the reference to the com exe, in the VBA editor, via Tools/References). To debug it, I set the path to Excel.exe in the Visual Studio Debug command and as argument I set the path to my xlsm file. Then I just call call the VBA code in Excel. It works for the com DLL but not for the COM Exe. I also tried by attaching VS to Excel and it didn't work.

我找到了这篇文章(Windows COM - 如何调试COM 服务器 ),这似乎是由提升/权限问题引起的,但我尝试了建议的答案,但没有奏效.

I have found this post ( Windows COM - how to debug a COM server ), it seems this is caused by a elevation/permission issue, but I tried the proposed answer but it didn't works.

有人可以帮我解决这个问题吗?

Does any one can help me with this ?

如何调试进程外 com 服务器?

是否有必要将调试器附加到使用 EXE 服务器的客户端(所以在我的情况下是 excel)?

Is it necessary to attach a debugger to the client that consumes the EXE server (so in my case to excel) ?

推荐答案

尝试调试 EXE 服务器很棘手.

It's tricky trying to debug an EXE server.

我要做的是修改注册表,以便在加载 EXE 时提示您调试.

What I would do is modify the registry so that you are prompted to debug the EXE when it is loaded.

这是用于修改注册表的导出 .reg 文件的内容:

Here is the contents of an exported .reg file used to modify the registry:

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution OptionsYourExeName.exe]
"debugger"="vsjitdebugger.exe"

将 YourExeName.exe 更改为更有用的内容...

Change YourExeName.exe to something more useful...

当您的 EXE 服务器启动时,系统会提示您启动调试器或从调试器的当前运行实例连接.已经有一个正在运行的调试器更快更好......当我说调试器"时,Visual Studio 的一个正在运行的实例就可以了.

When your EXE server is launched, you will be prompted to launch a debugger or attach from a current running instance of a debugger. It is faster and better to already have a debugger running... When I say "debugger", a running instance of Visual Studio is fine.

尝试调试 EXE 服务器时的一个问题是,当您设置断点并单步执行代码时,您可能会超过 COM 超时,然后调用您的进程的 EXE 客户端将因超时而失败,它只会继续执行.当一切都在进行中时,这不是问题.对于 EXE,在您认为可能有问题的区域中,在您的调试版本中包含更多 TRACE 语句可能会有所帮助.

A problem when trying to debug an EXE server is that when you set breakpoints and step through the code, you can exceed the COM timeout and then the EXE client calling your process will have a failed call due to timeout and it will just continue executing. When everything is in process, this is not such a problem. For an EXE, it might be helpful to have a lot more TRACE statements in your debug build in the area where you think you might have problems.

并不是绝对必须附加到客户端进程.有时它有帮助,有时则没有.如果您拥有调用客户端进程的源代码,显然会容易得多.

It is not strictly necessary to attach to the client process. Sometimes it is helpful, and sometimes not. It's obviously much more easier if you have the source code to the calling client process.

这篇关于如何调试 COM C++ 进程外服务器?(客户:Excel vba)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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