Remote Debugging with Visual Studio
Remote Debugging using Visual Studio enables you to debug code running on a different machine. This is useful in scenarios where an issue is hard to reproduce on your local machine, but is easily reproducible on a remote machine (e.g. a testers VM).
The steps below outline the process of setting up both your local machine (with Visual Studio installed) and the remote machine to enable remote debugging
1. Setting up the Remote Machine
- Download the appropriate version of the Remote Tools for Microsoft Visual Studio package from the links below. This needs to match the version of Visual Studio that you have installed on your machine. Links: Visual Studio 2012 Update 4 (x64), Visual Studio 2013 Update 4 (x64) , Visual Studio 2015(x86, x64, and ARM)
- Install the Remote Tools for Microsoft Visual Studio package on the remote machine
- Configure the client by running the Remote Debugger Configuration Wizard from the start menu
- Uncheck the “Run the Visual Studio Remote Debugger service” check box because we will be using the client application
- Allow the remote debugger to communicate across all the networks
- Run the Remote Debugger application on the Remote Machine
- Take note of the machine name and port that is displayed in the Client window(DDXVM6812:4020 from the example below)
2. Setting up your Local Machine
- Open up Visual Studio on your machine and open up the Project Properties of the project(s) that you want to debug(With the project selected: Alt + Enter or Right Click>Properties)
- Note: There’s no need to do it for all the projects in your solution - just do it for the one that contains the code that you need to debug
- On the Debug tab, check the Use remote machine option. In the textbox next to it, enter the address of the client from Step 1e.
- Save your changes and ensure that the project is set to build in the Configuration Manager
- Build the project(or the entire solution)
- Navigate to the build output folder in Windows Explorer (Right Click on the project in Solution Explorer and click on Open Folder in File Explorer and open the bin folder)
- Copy the .dll AND .pdb file of the project that you want to debug from the bin directory to the appropriate directory on the Remote Machine
3. Debugging the Project
- On the Remote Machine, launch the Program that you want to debug
- On your Local Machine In Visual Studio, set a breakpoint at the line of code that you want to debug
- Click on Debug > Attach to Process
- Set the Qualifier field to the remote client address(from Step 1e)
- Click on the Refresh button
- Click on the process for your application and click on Attach
- Visual Studio should now change to Debugging mode and your breakpoint will now be hit
Note: Any changes to the code will require you to rebuild the project and then copy the .dll and _.pdb _files to the remote machine. Edit and Continue is also not supported when debugging in this manner.