“附加到进程...”节省了大量-6ren">
gpt4 book ai didi

visual-studio - Visual Studio - "attach to particular instance of the process"宏

转载 作者:行者123 更新时间:2023-12-01 00:32:26 26 4
gpt4 key购买 nike

我想几乎所有进行大量调试的人在 Visual Studio 中都有一个方便的宏(在工具栏上有快捷方式),调用时会自动附加到特定进程(通过名称标识)。

它比单击“调试”->“附加到进程...”节省了大量时间,但它仅在运行要附加到的进程的单个实例时才有效。如果内存中有多个特定进程的实例 - 第一个(具有较小的 PID?)由调试器选择。

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

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?

如果有人拥有该宏或知道如何编写它 - 请分享。

谢谢。

最佳答案

您始终可以附加到所有实例...这是我在调试 asp.net 应用程序时使用的宏 - 这些应用程序通常同时具有 UI 和 Web 服务,我需要附加到两者。

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 - Visual Studio - "attach to particular instance of the process"宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2512935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com