开发者

Visual Studio - "attach to particular instance of the process" macro

开发者 https://www.devze.com 2022-12-24 19:19 出处:网络
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 (identif

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).

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 开发者_如何学Goselect 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?

If someone has that macro or knows how to write it - please share.

Thanks.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号