ReAttach gives you an easy way of reattaching to your prior debug targets. This is especially useful when working with IIS-processes, test runners and web browsers. ReAttach stores your attach history for you and provides both toolbar and menu options for easy access.
The hotkey sequence CTRL+R, CTRL+A is used to ReAttach to your latest target (top of the history list). If your process is not currently running, ReAttach will ask you to start it and attach to it as soon as it becomes available.
Older versions of Visual Studio (2010-2019)
Older versions of ReAttach (compatible with older versions of Visual Studio) can also be found pre-packaged in the GitHub repository here.
If you encounter problems with an extension on a particular version of VS, please let me know and try moving back to an earlier version.
- Support for Visual Studio 2022. Unfortunately at the cost of several older versions (see old versions).
- 10 history items instead of 5 (by popular demand).
- Support for Visual Studio 2019. Unfortunately at the cost of several older versions (see old versions).
- Build before ReAttaching: You can now enable auto rebuilding before reattaching to targets.
- Multiple debug engines: Reattach will now remember specific (and multiple) debugging engines and attach to them accordingly.
- Minor fixes: Various bugs and minor tweaks.
- Better UI support: You now have dedicated buttons and a toolbar that you can use to customize your experience (they're placed under the debug category).
- Multiple targets: Attached targets are temporarily hidden/disabled in the history. This allows you to ReAttach to multiple targets in a row using the top-level shortcut and hotkeys.
- More hotkeys: In addition to the original one, CTRL+R, CTRL+[1-5] can also be used, allowing attaching to older targets.
- Remote debugging support: Experimental for now. When you attach to a remote target the server required is also stored. When ReAttaching, a different transport qualifier is used.
- Minor fixes: A few bugs, language changes, UAC support etc.
The ReAttach menu controller dropdown showing several targets in the users ReAttach history.
How does it work?
When debugging is started and the underlying reason is a user attach, ReAttach stores process path, username and PID in the registry (in a subkey called ReAttach located under the currently running visual studio user's key). Once a ReAttach is made the following steps occurs:
- All candidates (running processes) with matching path and username are filtered out.
- If there's a candidate with a matching PID that process is immediately selected and attached to.
- If no direct match on PID can be found the process with the highest PID is selected and attached to.
- If no match at all is found, the user is presented with a modal dialog telling him/her to start the process or cancel.
When trying to ReAttach to a process that is not running, the user is prompted with a dialog waiting for the process to start. This can for example be helpful to catch exceptions in the startup sequence of a web application running on IIS.
The source code for this extension is available on GitHub. Feel free to fork it and add stuff you're missing.