如何在远程计算机上启动调试过程?

Har*_*lse 14 remote-debugging winforms

我正在为用C#编写的标准Windows Forms应用程序设置Visual Studio远程调试会话.

在互联网上有很多关于如何设置远程计算机和MSVCMON.EXE的故事,但我找不到任何关于如何在我的计算机上做什么的故事,以确保我的程序在远程计算机上调试按START START DEBUGGING.

那么我该怎样做才能进行远程调试呢?

Har*_*lse 17

经过一些研究后,我发现了如何做到这一点,即使你在一家公司工作,这个公司在防火墙等方面存在很多安全问题.我需要IT部门唯一需要的是两台计算机上的管理员权限.

先决条件:

  • 我在Visual Studio 2012 Professional中使用了这种方法,并在几年后再次在Visual Studio 2013 Ultimate中对其进行了测试.
  • 本地计算机和远程计算机都在同一个域中.
  • 我以域名成员身份登录.

怎么做:

  • 在远程计算机上:使用普通帐户登录.如果这是第一次为您创建新环境.
  • 在远程计算机上:确保您具有管理员权限.
  • 在远程计算机上:启用远程桌面.
  • 在本地计算机上找到Visual Studio的远程调试文件夹.
  • 在我的计算机上,这是:"C:\ Program Files(x86)\ Microsoft Visual Studio 11.0\Common7\IDE\Remote Debugger"
  • 将此文件夹复制到远程计算机上的类似(可查找)文件夹中.
  • 在远程计算机上从复制的文件夹中运行MsvsMon.exe.
  • 第一次它会做一些安装.让它改变防火墙.
  • 使用工具选项 - Windows身份验证
  • 使用工具权限确保您是具有调试权限的用户.

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