7
votes

How do I remote debug a managed application from other machine which has visual studio. This is what I have tried:

  1. Copy the remote debug folder which comes part of visual studio into remote machine and run msvsmon.exe (64 bit version as both machines are 64 bit).
  2. Use the same windows login account in both machines.
  3. Then I start visual studio and use attach to process. In the transport I select "Default" and in qualifier I give the hostname of the machine where msvsmon.exe is running.
  4. Then I press Refresh button to see the list of processes on that machine. I can see that on the other it says "User xyz is connected". However, the refresh fails and I get following error : Error screen

What am I doing wrong here? I am trying with VS2008 Pro and OS on both systems is Windows Server 2008 R2 if it matters.

Note: I can debug unmanaged applications using Remote transport without any issues.

5
Use the MSDN article. The firewall is the usual hangup, you didn't mention anything about it.Hans Passant
Be sure to also run msvsmon.exe on the remote machine As AdministratorPeter Ritchie

5 Answers

5
votes

Even though your machines are 64 bit, make sure the applications you are running are 64 bit. For example if you are debugging a 32 bit application on the remote machine, you would want to run the 32 bit version of msvsmon.exe

This may not be the answer, but something to check to make sure of.

Update in 2017

As I've been using remote debugging more over the past few years, I've noticed a few more issues that I usually have to work through.

  1. Make sure the same version of msvsmon is being used on each machine.
  2. Make sure authentication is correctly configured (try and get no authentication to work first, then turn it on later if you need it)
  3. Make sure when you attach to process, you have the correct "Attach To" settings (i.e. Managed .NET version, Native code, etc.)
  4. Make sure the msvsmon is running as Admin OR as the same user identity as the application you want to debug
3
votes

I also lost a lot of hours on this. The only way I've found to make it works 100%, is to use the same domain. With VS2012 it's easier to connect without being in the same domain.

But for 2008, this is working for me (A = VS side, B = machine without VS)

1) The machine A (where VS is) and B must be in the same domain. You also need to download and install VS Remote Debugger monitor on B

2) You need to start VS Remote debugger monitor on the B side, to allow incoming connection. When you start it the 1st time, it'll configure the firewall to open the ports. It also show you on which address it's listening, i.e. DOMAIN\User@hostname_B

3) Run VS with a domain admin account on A, and you'll be able to remotely debug. To connect to B in debug, use the address shown in step 2 by the monitor

Hope it'll help you !

2
votes

Starting with Visual Studio 2012 you can use the Remote (no authentication) transport to debug managed code (previously VS only allowed to debug native code in Remote mode).

2
votes

Not a direct answer to the OP, but might be useful all the same and has dug me out of similar situations a number of times.

I'd suggest considering installing WinDBG (or similar), ensuring you've got the correct symbols \ code setup use that to debug. There's a pretty steep learning curve for WinDBG, but I believe it's worth it, even at a very high level. It's extremely lightweight, meaning its useful in the context of the original post + also usable in production, etc. where installing something like VS typically isn't an option.

This probably isn't an option if you're in a rush, but it's worth doing in the long run.

Chris

PS: There are some v. good courses on the web, especially on sites like Pluralsight (I've no relation, except being a happy customer)

1
votes

I've spent a lot of time making this work. But I succeeded and now to fully debug my managed application. I follow this list of task to make it work:

-Add target PC to domain and login with the same account as you use on PC with Visual Studio.

-Run correct Visual Studio Remote Debugger (msvsmon.exe), I use 2010 version.

-Turn off firewall on target PC.

-Add exception to Windows firewall for devenv.exe (Visual Studio exe) on develop computer.

-If you use OracleVM for virtual PC, the Network adapter can't be in NAT mode (I used Bridged Adapter).

-Debug address to use is: DOMAIN\USER@PCNAME (e.g. MyGreatDomain\Myself@DEBUGPC).

-If I use "Debug->Attach to Process" window to start debugging, I need to also use "Select" button to edit "Attach to:" - I required Managed (v4.0) code, Native code.

-The pdb files must be in the same directory I use to run my exe. I mapped the directory with my exe and pdb directly into the target computer.

-In Visual Studio I also have to go to Tools->Options, expand Debugging->General. And uncheck Enable Just My Code (Managed only).

It's really complicated to make it work, but it saves so much time later...