All folks who work on VS and ASP.NET and work on multiple web projects/websites finds its very tedious to find and attach the right solution to right application pool. Go to command prompt, find application pool ID, go to debug -> attach process and attach it…..grrrrrrrrr!
I wrote a small macro which you can put in your macros and give it a short cut and will be really quick to do above of all and attach w3wp easily with 3 keyboard clicks.
=++++++++++++++++++ code snippet
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Windows.Forms
'Author: Mehul T - 1/12/2012
Public Module AcmeAttachProcessMacro
Public Sub AcmeAttachProcess()
Try
Dim process = New System.Diagnostics.Process()
process.StartInfo.FileName = "C:\Windows\system32\inetsrv\appcmd.exe"
process.StartInfo.Arguments = "list wp"
process.StartInfo.UseShellExecute = False
process.StartInfo.CreateNoWindow = True
process.StartInfo.RedirectStandardOutput = True
process.Start()
Dim output As String = process.StandardOutput.ReadToEnd()
process.WaitForExit()
Dim PID As String = InputBox(output, "Enter process ID from following list:")
If PID.Length > 0 Then
Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
For Each processEach In Processes
If (processEach.ProcessID = Int32.Parse(PID)) Then
processEach.Attach()
End If
Next
End If
Catch ex As Exception
MessageBox.Show("Error:" + ex.Message)
End Try
End Sub
End Module
++================================
#trivedimehulk@gmail.com
No comments:
Post a Comment