“Visual Studio”

编程入门 行业动态 更新时间:2024-10-08 06:21:06
本文介绍了“Visual Studio” - 附加到进程的特定实例“宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我猜Prety很多人都做了很多调试,在Visual Studio中有一个方便的宏(在工具栏上具有快捷方式),当它被自动附加到一个特定的进程(以名称标识)时。

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

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

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

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

谢谢。

解决方案

您可以随时附加到所有实例... 这是调试asp应用程序时使用的宏 - 这些宏通常都具有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 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”

本文发布于:2023-06-02 00:49:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/430980.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Visual   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!