How to debug a COM C++ Out of Process Server ? (client: Excel vba)

我是研究僧i 提交于 2019-12-06 00:31:18

It's tricky trying to debug an EXE server.

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

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"

Change YourExeName.exe to something more useful...

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!