从命令行附加Visual Studio调试器

时间:2022-07-31 01:32:45

I'm using vsjitdebugger.exe -p {pid} to attach the visual studio debugger to a running process. It works, but with the annoyance that a popup window prompts me to select a debugger to attach and I can either choose the open instance of visual studio or start a new instance. Is it possible to pass in the .sln file I want it to attach to so that I don't get that prompt? I could choose new instance as the default, but I was hoping I could specify a .sln file so that it would either open that solution or attach to it if it's already open.

我正在使用vsjitdebugger.exe -p {pid}将visual studio调试器附加到正在运行的进程。它有效,但是有一个烦恼,即弹出窗口提示我选择要附加的调试器,我可以选择Visual Studio的打开实例或启动一个新实例。是否可以传入我希望它附加的.sln文件,以便我得不到那个提示?我可以选择新实例作为默认实例,但我希望我可以指定.sln文件,以便它可以打开该解决方案,或者如果它已经打开则附加到它。

Thanks, Greg

Edit: I was hoping for a programmatic way of doing this. My application is being run by a testing framework and I want it to run without having to click on anything. The help dialog for vsjitdebugger.exe doesn't mention that what I want is possible. What I really want is the ability to do: vsjitdebugger.exe -p {pid} -s 'solution.sln' and bypass that popup.

编辑:我希望有一种程序化的方式来做到这一点。我的应用程序由测试框架运行,我希望它无需点击任何东西即可运行。 vsjitdebugger.exe的帮助对话框没有提到我想要的是可能的。我真正想要的是能够做到:vsjitdebugger.exe -p {pid} -s'solution.sln'并绕过该弹出窗口。

2 个解决方案

#1


1  

Have a look at this article, although it uses macro's you could convert into C# or vb.net reasonable easy.

看看这篇文章,虽然它使用宏,你可以很容易地转换成C#或vb.net。

http://www.codeproject.com/KB/macros/AttachedProcess.aspx

#2


0  

I am not sure whether the debugger allows the option of loading the solution when you launch it. It is not possible for the debugger to know which solution the executable belongs to as the the only argument being provided is the pid.

我不确定调试器是否允许在启动时加载解决方案。调试器不可能知道可执行文件属于哪个解决方案,因为提供的唯一参数是pid。

If you want to launch the process and debug it through visual studio solution, then the best way to do this would be to start the process and attach it to the debugger.

如果您想通过visual studio解决方案启动该过程并进行调试,那么最好的方法是启动该过程并将其附加到调试器。

More information on how to attach to process is at How to: Attach to a Running Process

有关如何附加到进程的更多信息,请参见如何:附加到正在运行的进程

Also, have a look at this question: Run Debug mode from command line

另外,看看这个问题:从命令行运行调试模式

#1


1  

Have a look at this article, although it uses macro's you could convert into C# or vb.net reasonable easy.

看看这篇文章,虽然它使用宏,你可以很容易地转换成C#或vb.net。

http://www.codeproject.com/KB/macros/AttachedProcess.aspx

#2


0  

I am not sure whether the debugger allows the option of loading the solution when you launch it. It is not possible for the debugger to know which solution the executable belongs to as the the only argument being provided is the pid.

我不确定调试器是否允许在启动时加载解决方案。调试器不可能知道可执行文件属于哪个解决方案,因为提供的唯一参数是pid。

If you want to launch the process and debug it through visual studio solution, then the best way to do this would be to start the process and attach it to the debugger.

如果您想通过visual studio解决方案启动该过程并进行调试,那么最好的方法是启动该过程并将其附加到调试器。

More information on how to attach to process is at How to: Attach to a Running Process

有关如何附加到进程的更多信息,请参见如何:附加到正在运行的进程

Also, have a look at this question: Run Debug mode from command line

另外,看看这个问题:从命令行运行调试模式