“Visual Studio” - 附加到进程的特定实例“宏 [英] Visual Studio - "attach to particular instance of the process" macro

查看:157
本文介绍了“Visual Studio” - 附加到进程的特定实例“宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我猜Prety很多人都做了很多调试,在Visual Studio中有一个方便的宏(在工具栏上具有快捷方式),当它被自动附加到一个特定的进程(以名称标识)时。



它节省了大量的时间,而不是点击调试 - >附加到进程...,但它只有在运行一个进程的单个实例时才有效附加到。如果该内存不是一个特殊进程的一个实例 - 第一个(具有较小的PID?)正在被调试器选择。



有没有人有一个宏显示一个对话框(如果更多的是具有指定名称的1个进程),并让开发人员选择一个他/她真正想要附加的对象。



我猜选择可以基于风幕字幕文本(在大多数情况下是足够的),并且当选择特定实例时,宏将进程的PID传递给调试器对象?



如果有人有这个宏或知道如何写它 - 请分享。



谢谢。

解决方案

您可以随时附加到所有实例...
这是调试asp.net应用程序时使用的宏 - 这些宏通常都具有UI和Webservice两者,我需要

  Sub AttachToAspNET()
尝试
Dim进程作为EnvDTE.Process

Dim listProcess作为新列表(Of String)
listProcess.Add(aspnet_wp.exe)
listProcess.Add(w3wp.exe)
listProcess.Add(webdev.webserver.exe)

对于每个进程在DTE.Debugger.LocalProcesses
对于每个procname As String在listProcess
如果进程。 Name.ToLower.IndexOf(procname)<> -1然后
process.Attach()
结束如果
下一个
下一个
ListDebuggedProcesses()
Catch ex As System.Exception
MsgBox (ex.Message)
结束尝试
End Sub


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 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?

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

这篇关于“Visual Studio” - 附加到进程的特定实例“宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆