' This routine attaches to the ASP.NET worker process Sub AttachTo_ASPNETWP() Dim attached As Boolean = False Dim proc As EnvDTE.Process Dim processToAttachTo As String ' name of the process to attach to processToAttachTo = "aspnet_wp.exe" ' iterate through all processes running on the local machine For Each 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 ' appach to the process proc.Attach() ' set a flag that we've attached to the process & exit the for loop attached = True Exit For End If Next ' if macro didn't find process running, notify user If attached = False Then MsgBox(processToAttachTo & " is not running") End If End Sub