如何在远程计算机上启动调试过程? [英] How do I start the debugging process on a remote computer?

查看:58
本文介绍了如何在远程计算机上启动调试过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

网上有很多关于如何设置远程计算机和MSVCMON.EXE的故事,但是我找不到任何关于如何在我的计算机上执行以确保我的程序在远程调试的故事当我按下开始调试时,计算机.

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?

推荐答案

经过一些研究,我找到了如何去做,即使您在一家存在很多防火墙等安全问题的公司工作.我需要 IT 部门提供两台计算机的管理员权限.

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.

先决条件:

  • 我在 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 身份验证
  • 使用工具权限确保您是具有调试权限的用户.

msvsmon.exe 程序现在应该正在等待新的连接.服务器的名称类似于远程计算机名称":端口号",例如Prototype1:4016.

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.

现在在您将使用 Visual Studio 开发程序的本地计算机上执行以下操作:

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

  • 打开 Visual Studio,并加载解决方案.
  • 如果还没有这样做:设置启动项目(右键单击启动项目并选择作为启动项目启动.
  • 启动配置管理器(单击带有调试/发布选项的组合框旁边的箭头,然后选择配置管理器...).
  • 在配置管理器活动解决方案配置"中选择新建.为新配置指定一个正确的名称,并将其从 Debug(可能)复制一份.
  • 为远程调试创建代码时,您必须选择新配置.
  • 需要更改此新配置的某些设置.例如,您必须确保构建结果代码后在远程计算机上.最简单的方法是双击启动项目的属性并选择构建选项卡.将输出路径从 bin\debug 更改为您想要代码的远程计算机上的位置.例如:\\Prototype1\Users\Harald\Documents\CameraTestProgram\.
  • 在相同的属性表单中,在调试选项卡上,选择调试会话应该在哪台计算机上:检查:使用远程机器"并填写与 MsvsMon.exe 相同的名称.在我的示例中:键入 Prototype1:4016.
  • 在 Visual Studio 中构建代码、设置断点并开始调试.
  • 使用远程桌面连接来控制您的 Windows 窗体.

如果您想调试用 C# 编写的普通 Windows 窗体应用程序,则此方法有效.我检测到如果你使用不安全的代码它甚至可以工作.如果您的程序包含 C++ 代码,则会出现一些警告,但可以忽略它们.

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.

微软对此的链接(2013 年 10 月生效,2015 年 8 月仍然有效):

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.

微软:如何设置远程调试.2017 年 6 月生效

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

这篇关于如何在远程计算机上启动调试过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆