.NET life

HUGON Jérôme
Microsoft Certified Technology Specialist Microsoft Certified Application Developer Microsoft Certified Professional

Remote debugging

Visual Studio

Category Visual Studio  | Publication Date : 7/5/2010

The introduction of remote debugging is problematic when both machines are not part of the same domain. The main requirement is that there must have a user account with the same name and same password on the remote machine and on the local machine (a local account and not a domain account). The second point is that Visual Studio Remote Debugger must be installed on the remote machine and be done with the user account.

Create the local account

From Windows

  • Right click on My Computer - Manage.
  • Expand Computer Management - System Tools - Local Users and Groups.
  • Right click Users under Local Users and Groups and choose New User ....
  • Enter the username and password.
  • Untick User must change password at next login and tick Password never expires and User can not change password.
  • Click on Create.
  • Click Close.

From the command line

Execute the following command:

net user RemoteDebugUser PASSWORD /fullname:"Remote debug Machine Account" /comment:"User for remote debugging" /passwordchg:no /expires:never /add

You need to update the user account by ticking the checkbox Password never expire

Create the remote account

From Windows

  • Login to the remote machine and repeat the steps from the Create local account section (username and password must be the same).
  • Right click the user then choose Properties.
  • Go on the Member Of tab.
  • Click Add....
  • Enter Administrators and then click OK.
  • Click OK.

From the command line

  • Login to the remote machine and repeat the steps from the Create local account section (username and password must be the same).
  • Execute the following command:

net localgroup administrators RemoteDebugUser /add

Install Visual Studio Remote Debugger

If Visual Studio is installed on the remote machine, the remote debugger too:

Visual Studio 2008

Remote debugging - Visual Studio

Visual Studio 2010

Remote debugging - Visual Studio

The installer for the Remote Debugger is on the installation disk of Visual Studio in the folder Remote Debugger.

The installer can also be downloaded from the Microsoft site: Visual Studio 2008 et Visual Studio 2010

There is an installer for each OS version (32-bit or 64 bit).

The installation is automatic and only the license agreement must be accepted.

At the end of the installation, configuration wizard opens. Refer to Configure Visual Studio Remote Debugger for details of the configuration.

Configure Visual Studio Remote Debugger

Configure the firewall

The Remote Debugger (msvsmon.exe) must be authorized to receive and transmit information on the network. DCOM (TCP port 135) and IPSEC (UDP port 4500 and UDP port 500) must be released.

Execute Visual Studio Remote Debugger

The version of the Remote Debugger (2005 / 2008 / 2010) on the remote machine must match the version of Visual Studio used on the local machine.

Execute as an application

Start Visual Studio 2010 Remote Debugger using the command Run as... and the user account created previously:

Remote debugging - Visual Studio

Execute as a service

Allow the user account to log on as a service:

  • Open Administrative Tools - Local Security Policy.
  • Expand Security Settings - Local Policies - User Rights Assignment.
  • Double click on Log on as a service under User Rights Assignment.
  • Click on Add User or Group....
  • Enter the username you created earlier and click OK.
  • Click OK and then close the Local Security Settings window.

Configure the service:

  • Start Visual Studio 2010 Remote Debugger Configuration Wizard.
  • Click Next.
  • Check the box Run the "Visual Studio 2010 Remote Debugger" service:

Remote debugging - Visual Studio

  • Click Next then Finish.

The Remote Debugger service names are the following depending on the version of Visual Studio:

Version   Service name
2005Visual Studio 2005 Remote Debugger
2008Visual Studio 2008 Remote Debugger
2010Visual Studio 10 Remote Debugger

Connect to the remote machine with Visual Studio

The version of Visual Studio (2005 / 2008 / 2010) on the local machine must match the version of the Remote Debugger used on the remote machine.

Open the menu Debug - Attach to Process...:

Remote debugging - Visual Studio

Log in using the user name created earlier and the name of the machine ([username]@[machinename]) in the Qualifier field then click on Refresh to get the list of process to attach:

Remote debugging - Visual Studio

Select the process and click on Attach.

Verify connections on the remote machine

If the Remote Debugger is running as an application on the remote machine, the window displays the connection:

Remote debugging - Visual Studio

If the Remote Debugger is running as a service on the remote machine, the connection can be verified from the Event Viewer in the log Application, an event type Information is created with the source Visual Studio 2010 Remote Debugger.