Subscribe

Close

Thank you for visiting!

Please consider subscribing to the RSS feed or following me on Twitter.

Faster Visual Studio Attach to Process Debugging

Visual Studio's Attach to process is an alternative to the good ol' F5 which builds your solution and lets you debug it. However Attach to process can be made a little bit easier using a few helpful tricks.

First of all, we need to add an external tool to Visual Studio:

  1. Go to Tools->External Tools and press Add to create a new tool.
  2. Fill in these values in the correct field:

    Title: list w3wp
    Command: %windir%\system32\inetsrv\appcmd.exe
    Arguments: list wp

    Make sure "Use Output window" is checked and remember what order your tool has in the list, for instance 4th. Press Ok.

Add external tool in Visual Studio

Remember that your w3wp processes will be in Visual Studio's output window when using this tool!

Now we want easy access to our tool. Let's give it a shortcut command:

  1. Go to Tools->Options->Environment->Keyboard.
  2. In the Show command containing box, search for tools.external
  3. Find the correct  Tools.ExternalCommandX where X matches the order of your tool in the external tools list, for instance 4.
    Assign shortcut keys to your command and press Ok. I use Alt+E.

Assign shortcuts in Visual Studio

Next up, we need to use the helpful Visual Studio extension ReAttach. Download and install it. It helps us reattach to the same w3wp process over and over again :-) I've written about ReAttach and debugging before.

Finally, let's assign some shortcut commands to Attach to process and reattach:

Using the same technique as last time:

  1. Search for Debug.AttachtoProcess and assign Alt+W
  2. Search for Debug.ReAttach and assign Alt+Q

Now you can first find your correct process under Alt+E, then attach to it using Alt+W and finally reattach using Alt+Q.

Maybe you want different shortcuts, feel free to do it your way.

To the top