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

查看:163
本文介绍了如何调试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.

有人可以帮助我吗?

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

是否有必要将调试器附加到使用EXE服务器的客户端上(因此以我的情况为佳)?

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_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\YourExeName.exe]
"debugger"="vsjitdebugger.exe"

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

Change YourExeName.exe to something more useful...

启动EXE服务器时,系统将提示您启动调试器或从调试器的当前运行实例进行附加.已有调试器运行会更快,更好....当我说"debugger"时,可以运行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天全站免登陆