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
120 views
in Technique[技术] by (71.8m points)

c# - How to set up remote debugging on a machine without Visual Studio

Is there a way to set up Remote Debugging (Msvscom.exe) on a machine that does not have Visual Studio installed?

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.

The Dev box is running Visual Studio 2010/Windows 7. The VM is running Windows 7 without Visual Studio.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

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:

  1. Visual Studio 2010 remote debugger. (Working as of 21/Oct/2016)
  2. Visual Studio 2013 remote tools (working as of 21/Oct/2016)
  3. Visual Studio 2015 remote tools x86 - Direct download link
  4. Visual Studio 2015 remote tools x64 - Direct download link
  5. Visual Studio Tools (Thanks Robo Burned)
  6. Visual Studio 2017 Remote Tools x64 - Direct download link (Thanks Isaac Baker)
  7. Visual Studio 2017 Remote Tools x86 - Direct download link (Thanks Isaac Baker)
  8. Visual Studio 2019 Remote Tools - download link

This is the setup I succeeded with today:

Host (Dev) Machine:
Windows 7 Ultimate SP1 x64. Running 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.

Network:
Both machines are on the same subnet. I access the remote machine via RDP and run my application that way.

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.

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.

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....

Run the Remote Debugger on the remote system and you'll see

Msvsmon started a new server named '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.

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.

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.


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

...