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

前端 未结 1 720
醉梦人生
醉梦人生 2020-12-14 03:54

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 se

相关标签:
1条回答
  • 2020-12-14 04:45

    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):

    • Microsoft description on how to setup remote debugging. This link does not work anymore on June 2017.

    • Microsoft: how to set up remote debugging. It worked in June 2017

    0 讨论(0)
提交回复
热议问题