Visual Studio Hotkey for Web Devs: Attach to W3WP

Friends keep asking for this, so here are the instructions:

  1. In VS2010 open the Tools / Macros / Macro IDE menu item
  2. Create or edit the MyMacros project
  3. Add a new Module called "AttachToProcess"
  4. Replace all the code with the following:
  5. Imports System
    Imports EnvDTE
    Imports EnvDTE80
    Imports EnvDTE90
    Imports EnvDTE90a
    Imports EnvDTE100
    Imports System.Diagnostics
    
    Public Module AttachToProcess
        Sub IISWorkerProcess()
            Dim attached As Boolean = False
            Dim process As EnvDTE.Process
    
            For Each process In DTE.Debugger.LocalProcesses
                If process.Name.EndsWith("w3wp.exe") Then
                    process.Attach()
                    attached = True
                End If
            Next
    
            If Not attached Then
                MsgBox("Couldn't find w3wp.exe")
            End If
    
        End Sub
    End Module
    
  6. Save this macro
  7. Close the Macro IDE
  8. Right click the VS2010 menu bar
  9. Select Customize...
  10. Click Keyboard...
  11. Select Macros.MyMacros.AttachToProcess.IISWorkerProcess from the lists of commands
  12. Enter a shortcut in the box (I use Ctrl+Alt+A)
  13. Click Assign, then OK, then Close
  14. Open a web application, browse to the site and test your macro
Enjoy!



Comments

  1. Very cool. I'm so used to typing Alt+d p w that I'd probably have to map this macro onto that key sequence ;-)

    ReplyDelete

Post a Comment

Popular posts from this blog

TFS to SVN Conversion with History

Simpler Tests: What kind of test are you writing?

Architecture at different levels of abstraction