Reputation: 36044
When I want to debug I have to do Debug->Attach to Process -> Look for a process in the list -> Attach.
I was wondering if I can create some kind of a shortcut to do this for me?
Upvotes: 72
Views: 43203
Reputation: 5140
To enable the 'Attach to Process' toolbar button in Visual Studio 2013, 2015, 2017, 2019, and 2022
Upvotes: 16
Reputation: 41
Alt+Shift+P to reattach the last attached process.
It works for me in Visual Studio 2017.
Upvotes: 4
Reputation: 1717
For Visual Studio 2017, 2019, there is a ReAttach extension available. Very handy.
Upvotes: 13
Reputation: 20050
Writing a macro is one option, however it cannot deduct which process to attach to by itself.
Another nice solution is to map the "Attach to process" command to a shortcut key:
(Tools -> Options -> Environment -> Keyboard, type attach, like i did in this example, and select a shortcut key):
Upvotes: 14
Reputation: 6071
I use this built in "Shortcut"
ALT+D, P, W, ENTER
this opens the debug menu, selects attach to process, scrolls down to w3wp.exe and attaches.
It's long but should work in multiple visual studio versions with no setup required, with or without resharper and it works when running multiple IIS processes as you can choose which process to attach to.
Upvotes: 12
Reputation: 11881
More: Search the VS Marketplace for "attach"
w3wp.exe
and it'll jump to that, then Enter to attach.System.Diagnostics.Debugger.Launch()
to your codeCurrent release is VS2015 at time of writing.
Go ahead and edit/extend this answer :-)
Upvotes: 0
Reputation: 824
You can use the Alt key shortcut ALT+D,P to launch the "Attach to Process" window via Debug menu.
Once there, you can use your keyboard to search the list of Available Processes (e.g. type "w3wp" if you want to attach to an IIS app pool)
Upvotes: 14
Reputation: 9455
Addins are probably a better way to do this now. I use one called "Attach to anything". You can find them in Visual Studio 2012. Go to "Tools" -> "Extensions and updates", search for "attach", and install "attach to anything".
Also see: Automate "Attach to Process" in Visual Studio 2012
Upvotes: 7
Reputation: 843
Personally I prefer to use Debugger.Launch() as suggested here in this thread, because it doesn't need for references to the DTE (that's IDE-specific and must be explicitly referenced into the project to be used)
Upvotes: 0
Reputation: 2652
This answer should work for Visual Studio 2010.
I like having buttons to do this on my debug toolbar
https://gist.github.com/1406827
The gist contains a method for attaching to IIS (w3wp.exe) or ASP (aspnet_wp.exe) and also nunit (nunit-agent.exe). Instructions are included on how to add the macros to your debug toolbar.
Upvotes: 13
Reputation: 754635
The easiest way to do this is to write a macro which finds the DTE.LocalProcess
you wan to target and automatically attach. For example
Public Sub AttachShortcut()
For Each proc In DTE.Debugger.LocalProcesses
If proc.Name = "what you're looking for" Then
proc.Attach()
Exit Sub
End IF
Next
End Sub
Note: This Stack Overflow Question is related and has a sample you may find useful
Upvotes: 23