Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.0Common7IDERemote 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 bindebug to the location on the remote computer where you want the code. For instance: \Prototype1UsersHaraldDocumentsCameraTestProgram.
  • 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):


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...