Tuesday, May 24, 2005

Macro to attach to asp.net process

You know how much of a pain it is to debug web apps in Visual Studio .Net? You either run the website (which takes forever) or have to attach to the aspnet_wp.exe by clicking [Alt]dp[Enter][Enter][Enter].

Finally! A macro to attach to the process automatically! Thanks to Dan.


Sub AttachToAspDotNet()
  Dim attached As Boolean = False
  Dim proc As EnvDTE.Process
  For Each proc In DTE.Debugger.LocalProcesses
    If (Right(proc.Name, 13) = "aspnet_wp.exe") Then
      proc.Attach()
      attached = True
      Exit For
    End If
  Next

  If attached = False Then
    MsgBox("aspnet_wp.exe is not running")
  End If
End Sub

2 comments:

Glen McGregor said...

Actually, this isn't working for me! Very sad. It works for others though.

If I figure out what's going wrong, I'll let you know.

Anonymous said...

Unfortunately this attaches to the native debugger, not the CLR debugger.

There appears to be no way to attach to the native debugger through a macro.. :(