C# 如何在没有 Visual Studio 的机器上设置远程调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11586500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set up remote debugging on a machine without Visual Studio
提问by CodeMan5000
Is there a way to set up Remote Debugging (Msvscom.exe) on a machine that does not have Visual Studio installed?
有没有办法在没有安装 Visual Studio 的机器上设置远程调试 (Msvscom.exe)?
I would like to attach to the service running on the VM so I can debug an issue in the code. I've done this before but both machines have had VS installed.
我想附加到 VM 上运行的服务,以便我可以调试代码中的问题。我以前这样做过,但两台机器都安装了 VS。
The Dev box is running Visual Studio 2010/Windows 7. The VM is running Windows 7 without Visual Studio.
Dev box 运行的是 Visual Studio 2010/Windows 7。VM 运行的是 Windows 7,没有 Visual Studio。
采纳答案by Brandon
I'm going to resurrect this because anyone who's tried to do this knows it's a complete pain in the ass every time, and that it changes slightly with every possible combination of host/remote system you can have.
我将重新启动它,因为任何尝试这样做的人都知道每次都非常痛苦,并且随着您可以拥有的主机/远程系统的每种可能组合,它都会略有变化。
Visual Studio Remote Tools Links:
Visual Studio 远程工具链接:
- Visual Studio 2010 remote debugger.(Working as of 21/Oct/2016)
- Visual Studio 2013 remote tools(working as of 21/Oct/2016)
- Visual Studio 2015 remote tools x86 - Direct download link
- Visual Studio 2015 remote tools x64 - Direct download link
- Visual Studio Tools (Thanks Robo Burned)
- Visual Studio 2017 Remote Tools x64 - Direct download link(Thanks Isaac Baker)
- Visual Studio 2017 Remote Tools x86 - Direct download link(Thanks Isaac Baker)
- Visual Studio 2019 Remote Tools - download link
- Visual Studio 2010 远程调试器。(截至 2016 年 10 月 21 日)
- Visual Studio 2013 远程工具(自 2016 年 10 月 21 日起工作)
- Visual Studio 2015 远程工具 x86 - 直接下载链接
- Visual Studio 2015 远程工具 x64 - 直接下载链接
- Visual Studio 工具(感谢 Robo Burned)
- Visual Studio 2017 远程工具 x64 - 直接下载链接(感谢 Isaac Baker)
- Visual Studio 2017 远程工具 x86 - 直接下载链接(感谢 Isaac Baker)
- Visual Studio 2019 远程工具 - 下载链接
This is the setup I succeeded with today:
这是我今天成功的设置:
Host (Dev) Machine:
Windows 7 Ultimate SP1 x64. Running Visual Studio 2010, .NET Framework 4.
主机(开发)机器:
Windows 7 Ultimate SP1 x64。运行 Visual Studio 2010、.NET Framework 4。
Remote Machine:
Industrial/Factory Floor PC running Windows Embedded Standard 32-bit. It looks/feels exactly like Windows 7. Running SP1. Visual Studio is not installed. Has the .NET framework 4.
远程机器:
运行 Windows Embedded Standard 32 位的工业/工厂车间 PC。它的外观/感觉与 Windows 7 完全一样。运行 SP1。未安装 Visual Studio。具有 .NET 框架 4。
Network:
Both machines are on the same subnet. I access the remote machine via RDP and run my application that way.
网络:
两台机器在同一个子网上。我通过 RDP 访问远程机器并以这种方式运行我的应用程序。
Microsoft-Proprietary Follicle-Deterioration Implementation:
Make note of your dev machine's user name and password. For some reason you have to create exactly the same user name and password on the remote machine. Because Microsoft.
Microsoft-Proprietary Follicle-Deterioration 实施:
记下您的开发机器的用户名和密码。出于某种原因,您必须在远程计算机上创建完全相同的用户名和密码。因为微软。
How I did it:
I downloaded the Visual Studio 2010 remote debugger from the link provided by @sJhonny. I had to switch off of Visual Studio 2013 in that article and over to 2010. If you care to go over the 2010 article with a fine-tooth comb to find the download, the link is right next to the "No one ever finds this helpful" link at the top. If not, just follow my link above.
我是如何做到的:
我从@sJhonny 提供的链接下载了 Visual Studio 2010 远程调试器。我不得不在那篇文章中关闭 Visual Studio 2013 并切换到 2010 年。如果您想用细齿梳浏览 2010 年的文章以找到下载,链接就在“没有人找到这个”旁边有用”链接在顶部。如果没有,只需按照我上面的链接。
Install that on the remote machine and run the configuration wizard. I left the defaults for the wizard:
在远程机器上安装它并运行配置向导。我保留了向导的默认值:
- "Run the 'Visual Studio ....." was checked off
- Username is LocalSystem and password is blank
- Allow only computers on the local network....
- “运行'Visual Studio .....”被选中
- 用户名为 LocalSystem 密码为空
- 只允许本地网络上的计算机....
Run the Remote Debugger on the remote system and you'll see
在远程系统上运行远程调试器,你会看到
Msvsmon started a new server named 'username@machinename...'
Msvsmon 启动了一个名为“username@machinename...”的新服务器
in the interface. So far so good. Run the application on the remote machine. On the dev machine, Ctrl+Alt+P in visual studio will open "Attach to Process" (It's also under the tools menu). I got a popup about my dev machine's firewall not being configured properly and was asked if I wanted to allow the connections etc... Say yes obviously.
在界面中。到现在为止还挺好。在远程机器上运行应用程序。在开发机器上,visual studio 中的 Ctrl+Alt+P 将打开“附加到进程”(它也在工具菜单下)。我收到一个关于我的开发机器的防火墙没有正确配置的弹出窗口,并被问到我是否想允许连接等......显然说是。
Enter the 'username@machinename' combination into the qualifier box... press Refresh and pray a little. Pray a little more a lot harder and you should see a list of the processes running on the remote machine. Select your process and attach to it.
在限定符框中输入“用户名@机器名”组合...按刷新并祈祷一下。多多祈祷,你应该会看到远程机器上运行的进程列表。选择您的流程并附加到它。
But my breakpoints don't work!?Of course they don't... because using the breakpoints in the same directory as the application on the remote machine would make too much sense. If you were lucky enough, you got warned about a breakpoint cache and got shown a dialog with a path.
但是我的断点不起作用!?他们当然不会……因为在与远程机器上的应用程序相同的目录中使用断点会很有意义。如果你足够幸运,你会收到关于断点缓存的警告并显示一个带有路径的对话框。
The dialog mentions something about it being correct relative to the remote machine. It's lying. It has nothing to do with the remote machine except that it forced you to create a brand new user over there with the same name as your current user because Microsoft. To get your breakpoints to work, follow the path on your dev machine (customizable in Tools>Options>Debugging>Symbols: Cache symbols in this directory) and copy your application's .pdb files over to that directory. You have to copy them over with every new build, unless there's an option to do it automatically; I haven't checked because I have yet to stop celebrating my remote debugging success.
该对话框提到它相对于远程机器是正确的。这是在说谎。它与远程机器无关,只是它迫使您在那里创建一个与当前用户同名的全新用户,因为 Microsoft。要使断点起作用,请按照开发机器上的路径(可在工具>选项>调试>符号:此目录中的缓存符号中自定义)并将应用程序的 .pdb 文件复制到该目录。您必须在每个新构建中复制它们,除非有自动执行的选项;我还没有检查,因为我还没有停止庆祝我的远程调试成功。
Everything should work now.
现在一切都应该工作了。
I hope that helps someone save the hours of blinding rage I've endured trying to get this to work on different machines over the years.
我希望这能帮助别人节省我多年来试图让它在不同机器上工作所忍受的令人眼花缭乱的愤怒时间。
回答by J. Ed
certainly there is.
You can install msvsmon without installing visual studio.
I've done this myself on several machines.
the tricky part lays in authorization- the user running VS on your local machine needs special priviliges on the remote machine.
ms has some articles explaining the details- http://msdn.microsoft.com/en-us/library/bt727f1t.aspx,
当然有。
您可以在不安装 Visual Studio 的情况下安装 msvsmon。
我自己在几台机器上做过这个。
棘手的部分在于授权——在本地机器上运行 VS 的用户需要在远程机器上的特殊权限。
ms 有一些解释细节的文章- http://msdn.microsoft.com/en-us/library/bt727f1t.aspx,
回答by Robert Andrzejuk
Taken from: how-to-implement-remote-debugging-in-visual-studio-2005
摘自: how-to-implement-remote-debugging-in-visual-studio-2005
Let's consider an example to understand this situation clearly. Molly Clark and Adam Barr are both employees at Adventure Works. Adventure Works has a Microsoft Windows NT domain named adventure-works.com. Adam is having trouble with some software that Molly wrote. Molly would like to debug this software on Adam's computer. Molly and Adam follow these steps:
- Adam doesn't have the remote debugger on his computer. To set up the remote debugger, Molly decides to share out the Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger directory on her computer. She creates a file share called Remote.
- Adam runs \MollyComputerName\Remote\x86\Msvsmon.exe.
- After the remote debugger starts, Adam clicks Permissions on the Tools menu to configure the remote debugger by using the Permissions dialog box. He gives Molly permission to debug.
NoteAdam could also configure the remote debugger by passing the /allow option when the remote debugger starts.- Molly starts Visual Studio 2005.
- To open the Attach to Process dialog box, Molly clicks Attach to Process on the Tools menu.
- Molly connects to Adam's computer by entering adventure-works.com\Adam@AdamComputerName in the Qualifier box.
- Under Available Processes, Molly selects the worker process that her application is using and then clicks Attach.
- Molly opens a browser and provides the URL to the remote application. The execution stops where the breakpoint is placed in the application.
让我们考虑一个例子来清楚地理解这种情况。Molly Clark 和 Adam Barr 都是 Adventure Works 的员工。Adventure Works 有一个名为 Adventure-works.com 的 Microsoft Windows NT 域。Adam 在使用 Molly 编写的某些软件时遇到了问题。Molly 想在 Adam 的计算机上调试这个软件。莫莉和亚当遵循以下步骤:
- Adam 在他的计算机上没有远程调试器。为了设置远程调试器,Molly 决定共享她计算机上的 Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger 目录。她创建了一个名为 Remote 的文件共享。
- Adam 运行 \MollyComputerName\Remote\x86\Msvsmon.exe。
- 远程调试器启动后,Adam 在工具菜单上单击权限以使用权限对话框配置远程调试器。他允许 Molly 进行调试。
注意Adam 还可以通过在远程调试器启动时传递 /allow 选项来配置远程调试器。- Molly 启动 Visual Studio 2005。
- 要打开“附加到进程”对话框,Molly 单击“工具”菜单上的“附加到进程”。
- Molly 通过在 Qualifier 框中输入 Adventure-works.com\Adam@AdamComputerName 连接到 Adam 的计算机。
- 在可用进程下,Molly 选择她的应用程序正在使用的工作进程,然后单击附加。
- Molly 打开浏览器并提供远程应用程序的 URL。执行在应用程序中放置断点的地方停止。
回答by Isaac Baker
Update: Here's the links for 2017 which are not obvious to find either.
更新:这是 2017 年的链接,也不太容易找到。
Visual Studio Remote Tools Links x64 direct link
回答by CaptonMike
I was able to get it working with asp.net core 2.1, the only difference from the answers above was that the process you attach to is dotnet.exe.
我能够让它与 asp.net core 2.1 一起工作,与上述答案的唯一区别是您附加到的进程是 dotnet.exe。
回答by mr R
There's also another way which I prefer (if you have fast internet connection).
还有另一种我更喜欢的方式(如果你有快速的互联网连接)。
You don't have to download or install anything on remote desktop connection.
您无需在远程桌面连接上下载或安装任何东西。
You can share your disk
C:while connecting via Remote Desktop Connection.On the remote desktop go to location (depending on your local location)
\tsclient\C\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\Remote Debugger\x64(optional) Create shortcut to folder or msvsmon.exe on desktop
- Run it remotely from your local disk via shared disk. (start can take few seconds depending on your connection quality)
您可以
C:在通过远程桌面连接进行连接时共享您的磁盘。在远程桌面上转到位置(取决于您的本地位置)
\tsclient\C\Program Files (x86)\Microsoft Visual Studio17\Enterprise\Common7\IDE\Remote Debugger\x64(可选)在桌面上创建文件夹或 msvsmon.exe 的快捷方式
- 通过共享磁盘从本地磁盘远程运行它。(启动可能需要几秒钟,具体取决于您的连接质量)
Option2: Copy Remote Debugger\x64 or x86 folder to the remote location and use it.
选项 2:将 Remote Debugger\x64 或 x86 文件夹复制到远程位置并使用它。


