Visual Studio - “附加到进程的特定实例"宏 [英] Visual Studio - "attach to particular instance of the process" macro
问题描述
我猜几乎所有进行大量调试的人在 Visual Studio 中都有一个方便的宏(在工具栏上有指向它的快捷方式),当调用它时会自动附加到特定进程(按名称标识).
I guess prety much everyone who does a lot of debugging have a handy macro in Visual Studio (with shortcut to it on a toolbar) which when called automatically attaches to a particular process (identified by name).
它节省了大量时间,而不是单击调试"->附加到进程...",但它只有在运行一个想要附加到的进程的单个实例时才有效.如果内存中有多个特定进程的实例 - 调试器正在选择第一个(PID 较小?).
it saves a lot of time rather than clicking "Debug" -> "Attach to the process ...", but it only works if one is running a single instance of the process one wants to attach to. If theres is more than one instance of particular process in memory - the first one (with a smaller PID?) is being choose by debugger.
有没有人有一个宏来显示一个对话框(如果有多个具有指定名称的进程正在运行)并让开发人员选择他/她真正想要附加到的一个.
Does anyone have a macro which shows a dialog (if more that 1 process with a specified name running) and lets developer to select to one he/she really wants to attach to.
I guess the selection could be made based on a windwow caption text (which would be suffice in most of cases) and when the particular instance is selected macro passes the PID of the process to the Debugger object?
I guess the selection could be made based on a windwow caption text (which would be suffice in most of cases) and when the particular instance is selected macro passes the PID of the process to the Debugger object?
如果有人拥有该宏或知道如何编写它 - 请分享.
If someone has that macro or knows how to write it - please share.
谢谢.
推荐答案
您始终可以附加到所有实例...这是我在调试 asp.net 应用程序时使用的宏——这些应用程序通常同时具有 UI 和 Web 服务,我需要附加到两者.
You can always attach to all instances... Here is a macro I used when debugging asp.net applications - these typically have both a UI and a Webservice and I need to attach to both.
Sub AttachToAspNET()
Try
Dim process As EnvDTE.Process
Dim listProcess As New List(Of String)
listProcess.Add("aspnet_wp.exe")
listProcess.Add("w3wp.exe")
listProcess.Add("webdev.webserver.exe")
For Each process In DTE.Debugger.LocalProcesses
For Each procname As String In listProcess
If process.Name.ToLower.IndexOf(procname) <> -1 Then
process.Attach()
End If
Next
Next
ListDebuggedProcesses()
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
这篇关于Visual Studio - “附加到进程的特定实例"宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!