调试时可以通过编程方式与Visual Studio调试器通信吗?

问题描述:

我想控制调试器上的选项,而不使用调试GUI,最好是从正在调试的代码内部。我会认为这将是相当困难的,但也许我的调试代码可以请求独立代码的服务,将与调试器通信。

I would like to control options on the debugger without using the debugging GUI's, preferably from inside the code being debugged. I would think that would be quite difficult, but maybe my debugged code can request a service from independent code that will communicate with the debugger.

这涉及到我的另一个问题控制什么时候打破

This relates to another question of mine on controlling when to break on exceptions.

您可以编写可以做任何GUI的Visual Studio宏,但他们可以参与其中。请参阅有关 Visual Studio的自动化和可扩展性的MSDN文档

You can write Visual Studio macros that can do anything the GUI can, but they can get rather involved. See the MSDN documentation on Automation and Extensibility for Visual Studio

从被调试的代码中执行此操作会很棘手,您一定需要与VS进行一些新形式的通信,也许是一个自定义加载项。我不认为一个独立的服务在这里会有根本的帮助。最大的问题是您的代码将在调试器中断时停止运行。

Doing this from the code being debugged would be tricky, you would definitely need some new form of communication with VS, maybe a custom add-in. I don't think an independent service would fundamentally help here. The biggest problem is that your code will stop running when the debugger breaks.