Created
October 25, 2011 21:07
-
-
Save amirrajan/1314280 to your computer and use it in GitHub Desktop.
attach to iis process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Imports EnvDTE | |
Imports EnvDTE80 | |
Imports EnvDTE90 | |
Imports EnvDTE90a | |
Imports EnvDTE100 | |
Imports System.Diagnostics | |
Public Module AttachToIIS | |
Public Sub AttachToIIS() | |
Dim AspNetWp As String = "aspnet_wp.exe" | |
Dim W3WP As String = "w3wp.exe" | |
If Not (AttachToProcess(AspNetWp)) Then | |
If Not AttachToProcess(W3WP) Then | |
System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro") | |
End If | |
End If | |
End 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 = False | |
For 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment