Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Created August 7, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewconnell/d55e58998a32881f4aab8dc3f6f15c6c to your computer and use it in GitHub Desktop.
Save andrewconnell/d55e58998a32881f4aab8dc3f6f15c6c to your computer and use it in GitHub Desktop.
' This routine attaches to the ASP.NET worker process:
Sub AttachTo_ASPNETWP()
Dim attached AsBoolean = False
Dim proc As EnvDTE.Process
Dim processToAttachTo AsString
' name of the process to attach to
processToAttachTo = "aspnet_wp.exe"
' iterate through all processes running on the local machine
ForEach proc In DTE.Debugger.LocalProcesses
' if the last [X] characters of the process name = name of the process...
If (Right(proc.Name, Len(processToAttachTo)) = processToAttachTo) Then
' attacj to the process
proc.Attach()
' set a flag that we've attached to the process & exit the for loop
attached = True
ExitFor
EndIf
Next
' if macro didn't find process running, notify user
If attached = False Then
MsgBox(processToAttachTo & " is not running")
EndIf
EndSub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment