How do I start the debugging process on a remote computer?

16,688

After some research I have found how to do it, even if you are working in a company that has a lot of safety issues with firewalls, etc. The only thing that I need from the IT department is administrator rights on both computers.

Prerequisites:

  • I used this method in Visual Studio 2012 Professional and tested it again a few years later in Visual Studio 2013 Ultimate.
  • Both the local computer and the remote computer were in the same domain.
  • I logged in as a member on the domain.

How to do it:

  • On the remote computer: log in using your normal account. If this is the first time a new environment is created for you.
  • On the remote computer: make sure you have administrator rights.
  • On the remote computer: enable remote desktop.
  • On the local computer find the remote debugging folder of your Visual Studio.
  • On my computer this was: "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Remote Debugger"
  • Copy this folder to a similar (findable) folder on the remote computer.
  • On the remote computer run MsvsMon.exe from the copied folder.
  • The first time it will do some installation. Let it change the firewall.
  • Use Tools Options - Windows Authentication
  • Use Tools Permissions to make sure you are a user that has debug rights.

The msvsmon.exe program should now be waiting for new connections. The name of the server is something like "remote computer name" : "port number", for instance Prototype1:4016.

Now on the local computer where you will develop your program using Visual Studio do the following:

  • Open Visual Studio, and load the solution.
  • If not already done so: set the startup project (right click on the startup project and select start as start-up project.
  • Start the configuration manager (click on arrow next to the combobox with the debug / release selection and select configuraton manager...).
  • In the configuration manager "Active solution configuration" select new. Give the new configuration a proper name, and make it a copy from Debug (probably).
  • When creating code for your remote debugging, you'll have to select the new configuration.
  • Some settings of this new configuration need to be changed. For instance, you'll have to make sure that after building the result code is on the remote computer. The easiest way is to double click the properties of the start-up project and select the build tab. Change the output path from bin\debug to the location on the remote computer where you want the code. For instance: \\Prototype1\Users\Harald\Documents\CameraTestProgram\.
  • In the same properties form, on the Debug tab, select on which computer the debug session should be: check: use remote machine" and fill in the same name as in the MsvsMon.exe. In my example: type Prototype1:4016.
  • In Visual Studio build your code, set your breakpoints and start debugging.
  • Use remote desktop connections to control your windows form.

This method works if you want to debug a normal Windows Forms application written in C#. I detected that it even works if you use unsafe code. There are some warnings though if your program contains C++ code, but they can be ignored.

Microsoft links for this (worked October 2013, and still in August 2015):

Share:
16,688

Related videos on Youtube

Harald Coppoolse
Author by

Harald Coppoolse

Taught by Professor Dijkstra, so I'm conditioned like a Maslov dog to make software how it "ought" to be done, not for fast hacks, which sometimes is a drawback, except if you're working in projects with a lot of people that need to keep working for years and years continuously changing it. Learned to use C# nine years ago after using C++ for over 25 years. "Finally a language that is well designed". Hurray! Never have to use a macro again contact: [email protected]

Updated on June 26, 2022

Comments

  • Harald Coppoolse
    Harald Coppoolse over 1 year

    I'm setting up a Visual studio remote debugging session for a standard Windows Forms application written in C#.

    On the Internet are a lot of stories about how to set up the remote computer and MSVCMON.EXE, but I can't find any stories about what to do on my computer to make sure that my program is debugged on the remote computer when I press START DEBUGGING.

    So what should I do to make remote debugging possible?

  • RonnBlack
    RonnBlack over 8 years
    Very helpful description that got me on the right track. I was debugging a website and I simply needed to copy the "Remote Debugger" folder to the server, Run the MsvsMon.exe program (as administrator) on the server. Then in VS 2013 on my local system I just needed to select "Debug/Attach to Process" and specify the Qualifier field as "servername:4108". It would then list the processes on the remote server and I could attach to w3wp.exe.