views:

353

answers:

4

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?

A: 

Debug->Attach to Process

Start typing the name of the process "w3wp" and it will immediately find it in the list.

esac
+1  A: 

You could write a macro and assign it to a toolbar button.

Chris Mullins
+9  A: 

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.

Ben M
Or you could just put Environment.MachineName.ToString in place of "COMPUTERNAME".
Nissan Fan
Yeah--this macro code isn't the best: it was originally a recorded macro.
Ben M
+2  A: 

You should be able to debug IIS just as if you are using the Visual Studio web server (Cassini):

  1. Show Properties for you ASP.NET project.
  2. Select the Web tab.
  3. In the Servers section select Use Local IIS Web server. Fill in the Project Url.
  4. Run your project in the debugger by hitting F5 (Debug => Start Debugging).

If you are running on Vista or newer with UAC enabled you will have to run Visual Studio as administrator for this to work. Right click on the Visual Studio shortcut and select Run as Administrator.... Accept the prompt to elevate priviledges.

Martin Liversage