How can I debug faster in Visual Studio?

asp.net, iis-7, visual-studio

Solution

I have a macro for this very purpose. In the tools menu, open up Macros -> Macros IDE. In the lefthand pane, double-click MyModule (or create a new module) and paste in this code:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module MyModule
    Sub AttachToIIS()
        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim dbgeng(2) As EnvDTE80.Engine
            dbgeng(0) = trans.Engines.Item("T-SQL")
            dbgeng(1) = trans.Engines.Item("Managed")
            Dim proc2 As EnvDTE80.Process2 = _
                dbg2.GetProcesses(trans, Environment.MachineName).Item("w3wp.exe")
            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try      
    End Sub
End Module

Then, you can edit your keyboard shortcuts and set this to a new combination; I use Ctrl+Shift+A. The command to invoke will be `Macros.MyMacros.MyModule.AttachToIIS`.

EDITED: changed "COMPUTERNAME" to `Environment.MachineName`.

Problem

Every time I have to go to attach to process, then scroll down and find w3wp.exe Is there a faster way to do this?

Original source