Reattach To Process in Visual Studio 2017

Sometimes when developing an application you can’t simply F5 to start debugging the application. In these cases you can use Attach to Process to debug. Many times if you need to debug this way, you will often need to attach to the same application repeatedly. In Visual Studio 2017 we have introduced Reattach to Process (Shift+Alt+P) to easily allow you to start debugging your application in one click without needing to go through the Attach to Process dialog every time.

You will still have to manually attach to your process the first time you open Visual Studio. However, we have also added a new search filter in the Attach to Process dialog to get you to your target application faster.

Attach to Process Search Filter

Once you open the Attach to Process dialog from the Debug/Attach to Process… (Ctrl+Alt+P) menu item, the search filter appears at the top of the available processes list. AttachToProcessFilter1

Type in the name of the process you want to attach to and select it from the list. This search filter is ‘sticky’ meaning that the next time you open up the Attach to Process dialog your previous search will be applied to the list. You can clear it by clicking the ‘x’ in the search filter box and it will reset to blank the next time you open the dialog.

AttachToProcessFilter

Reattach To Process

After you have successfully attached to a process from the Attach to Process dialog, a new Reattach to Process (Shift+Alt+P) command will appear in the Debug menu.

ReattachToProcess1

When triggered “Reattach to Process” remembers the last process you were attach to and will automatically attach the debugger to that process.

ReattachToProcess

Special Notes

The debugger will first try to find the exact process by matching process ID and name. If that cannot be found, then the debugger will look for the process by name only. If there is just one match found the debugger will automatically attach. If multiple matching names are found, the debugger will show the Attach to Process dialog for you to select the intended target.

Reattach to Process provides support for reattaching to multiple processes. For example, if you used the Attach to Process dialog to debug five different processes in one debug session, and then chose Reattach to Process, if all five processes are available the debugger will automatically attach to them all. If the debugger cannot find a matching process, or finds multiple matching processes, it will attach to what it can find and then show you an error message informing you what it did not attach to and why. Then it will open the Attach to Process dialog so you can manually select any missing processes or hit cancel and continue debugging the processes that were found.

image

Wrap Up

The Attach to Process search filter and Reattach to Process command improve your productivity by helping you get to the code you want to debug faster. Try it out by downloading Visual Studio now (https://www.visualstudio.com/downloads/) and let me know what your think! We are always wanting your feedback so drop your questions and comments in the section below, or tweet @VS_Debugger.

5