Debugging macro for VS.NET

I’ve found the macro below for starting debugging a massive time-saver. Much easier than going through the ‘attach to process’ UI screens all the time.

The steps below can be used to add a button to a toolbar in VS for attaching to IIS/IISExpress.

Tools -> Macros -> Macros IDE

Right-click MyMacros -> Add -> Add Module

Name: DebuggingMacros

Paste the code below into the module.

Public Sub AttachToWebServer()
        Dim Processes As New System.Collections.Generic.List(Of String)
        Dim Attached As Boolean = False
        For Each Proc In Processes
            If (AttachToProcess(Proc)) Then
                Attached = True
            End If
        If (Not Attached) Then
            System.Windows.Forms.MessageBox.Show("Can't find web server process")
        End If
    End Sub

Right-click toolbar -> customize -> commands tab -> Toolbar radio -> Build -> Add Command

Select Macros from the categories list, Macros.MyMacros.DebuggingMacros.AttachToWebServer from the list of commands on the right.

Rename the button to ‘Attach to IIS’ (or whatever you want).

To use, simply click on the button to attach the debugger to IIS/IISExpress.

Leave a Reply

Your email address will not be published. Required fields are marked *