During today’s debugging session at Basta, I’m going to mention the following Macro which allows you to add an “Attach to IIS”-Button to your Visual Studio toolbar:
Public Module DebuggingMacros
Public Sub AttachToWebServer()
Dim AspNetWp As String = "aspnet_wp.exe"
Dim W3WP As String = "w3wp.exe"
If Not (AttachToProcess(W3WP)) Then
If Not AttachToProcess(AspNetWp) Then
System.Windows.Forms.MessageBox.Show("Can't find web server process") End If
End IfEnd Sub
Public Function AttachToProcess(ByVal ProcessName As String) As Boolean
Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
Dim Process As EnvDTE.Process
Dim ProcessFound As Boolean = FalseFor Each Process In Processes
If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = ProcessName) Then
Process.Attach()
ProcessFound = True
End If
Next
AttachToProcess = ProcessFound
End Function
End Module
Comments
You can follow this conversation by subscribing to the comment feed for this post.