66

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.

Boann
  • 48,794
  • 16
  • 117
  • 146
CodeMan5000
  • 1,067
  • 2
  • 12
  • 21

6 Answers6

121

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.

starball
  • 20,030
  • 7
  • 43
  • 238
Brandon
  • 4,491
  • 6
  • 38
  • 59
  • Link for VS2015 is broken – Robo Burned Oct 06 '16 at 15:48
  • 2
    "Remote Tools for Visual Studio 2015" is now available under collapsible area "Tools for Visual Studio 2015" on https://www.visualstudio.com/downloads/ – Robo Burned Oct 06 '16 at 16:10
  • Awsome! Thank you for this, technically brilliant step-by-step descriptions (and I also like the irony since I made similar experiences ... ;-) One more hint: You can use [this link @ microsoft](https://msdn.microsoft.com/library/y7f5zaaa.aspx) for the remote tools and select "Other Versions" if you require to download older versions. So you just need one link (bookmark) for all. – Matt Oct 27 '16 at 09:02
  • Because Microsoft ... the link above is valid, but I just noticed that for **Visual Studio 2915 Update 3** you need a different link: [https://www.visualstudio.com/downloads/#remote-tools-for-visual-studio-2015-update-3](https://www.visualstudio.com/downloads/#remote-tools-for-visual-studio-2015-update-3) (scroll down until you find **Remote Tools for Visual Studio 2015 Update 3** on the left side) – Matt Oct 27 '16 at 09:11
  • Regarding debugging you wrote: You have to copy them over with every new build ... right, that's cumbersome, and I would prefer to have the .PDBs in the same directory with the binaries - but to do this automatically you can create a post-build action for this. – Matt Oct 27 '16 at 10:46
  • @Matt Yes, you can create a post-build but you'll run into problems if your solution is under source control and you accidentally commit it. Build server explosions etc.... – Brandon Oct 27 '16 at 13:33
  • Good point. I created it outside of the mapped folder so you can't accidently check it in. – Matt Oct 27 '16 at 13:48
  • One more question - have you ever set up remote debugging in a cross-domain environment (e.g. your PC being in one domain, the web server being in a different - test - domain)? I didn't find the host on which the remote debugging tool was running. Do you have a hint, maybe? I was using a Windows account as debug user and don't want to turn of authentication. – Matt Oct 28 '16 at 07:50
  • I've tried to do it a few times but was never successful. You need to be able to see (ping etc...) the debug target from your development machine. I've learned more about remote debugging since I posted the answer but haven't had time to update. The most important part is the authentication to the target. In my experience (and someone can correct this statement) if your credentials don't match *exactly* you're just not getting in. Ever. You need to find a way to impersonate your user on the remote domain. There's probably some additional setup you can do somehow that I don't know of. – Brandon Oct 28 '16 at 12:54
  • I learned that the 2015 tools listen on port 4020 and VS17 connects to 4022. Are there even tools for 2017? Could not find them. – usr Apr 24 '17 at 16:31
  • I'm not sure... 2017 is new so possibly they haven't been released? I unfortunately don't work in Visual Studio anymore so my knowledge will be stale. – Brandon Apr 24 '17 at 16:40
  • 1
    Just want to add my experience. In my qualifier field, I was never able to Find successfully. Instead I put in the computer IP and port and pressed Refresh. Also, you have to use the remote debugging tool that exactly matches the VS version on your dev machine. It seems like there is no backwards compatibility. – user2619824 Apr 26 '17 at 18:41
  • Also, the remote tools for VS2017 are located here https://www.visualstudio.com/downloads/ under Tools for Visual Studio 2017 – user2619824 Apr 26 '17 at 20:54
  • One more comment, I just tested this and I didn't have to make a user account on my remote machine. The usernames could be different. I'm on Windows 7 both machines and have VS 2012 update 3. – user2619824 Apr 27 '17 at 23:43
  • How to attach to remote Windows Service, not Process/Application. The above method works but only lists processes, I need to attach to service or application which shows in task manager. – Koder101 Oct 05 '17 at 09:41
  • @Koder101 There should be a checkbox for "Show processes from all users". Click that. – Brandon Oct 05 '17 at 15:09
  • What if I'm using dotnetcore on linux? how do I debug? – NullVoxPopuli Aug 01 '18 at 12:52
  • @NullVoxPopuli I'm not sure. I haven't used DotNetCore yet. I'd check if there's any documentation – Brandon Aug 02 '18 at 16:52
  • I followed @Brandon 's process more or less and got it to work. Having the target system run the exe *remotely* from the dev system was the instruction I must have missed that got it to work. – amalgamate Jan 16 '20 at 21:55
19

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,

J. Ed
  • 6,692
  • 4
  • 39
  • 55
10

Update: Here's the links for 2017 which are not obvious to find either.

Visual Studio Remote Tools Links x64 direct link

Visual Studio Remote Tools Links x86 direct link

Isaac Baker
  • 323
  • 2
  • 10
3

Taken from: 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.
    Note Adam 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.
Robert Andrzejuk
  • 5,076
  • 2
  • 22
  • 31
2

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.

  1. You can share your disk C: while connecting via Remote Desktop Connection.

    Remote Dekstop - Share Local Resources

  2. On the remote desktop go to location (depending on your local location)

    \\tsclient\C\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Remote Debugger\x64
    
  3. (optional) Create shortcut to folder or msvsmon.exe on desktop

  4. Run it remotely from your local disk via shared disk. (start can take few seconds depending on your connection quality)

Option2: Copy Remote Debugger\x64 or x86 folder to the remote location and use it.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mr R
  • 997
  • 2
  • 12
  • 25
0

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.

CaptonMike
  • 31
  • 5