How to: Set Up Remote Debugging 

This topic applies to:

Visual Studio Edition

Visual Basic

C#

C++

J#

Web Dev

Express

No

No

No

No

No

Standard

No

No

No

No

No

Pro/Team

Yes

Yes

Yes

Yes

Yes

Remote debugging setup is greatly simplified in Visual Studio 2005. All remote debugging scenarios except T-SQL debugging use the Remote Debugging Monitor (msvsmon.exe). The Machine Debug Manager (mdm.exe), previously required for some debugging scenarios, has been eliminated. In addition, msvsmon.exe now has a graphical user interface in place of the previous command-line interface.

To enable remote debugging, you can either:

  • Install the Remote Debugging Monitor on the remote machine and launch it when you start debugging, or

  • Run the Remote Debugging Monitor remotely from a share.

Running the Remote Debugging Monitor off of a file share is the easiest way to enable remote debugging. Visual Studio installs msvsmon.exe into these directories:

Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86

Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x64

Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\ia64

The 64-bit components are installed only on 64-bit platforms.

By sharing out the Remote Debugger directory on the Visual Studio machine, you can run msvsmon.exe on the remote machine.

The following debugger features do not work when the Remote Debugging Monitor is run from a share:

  • Debugging on Windows 98 or Windows ME

  • Stepping into an XML Web service. (Manual attach is still possible.)

  • Automatically debugging an ASP.NET Web application or an ATL Server-based ISAPI extension. (Again, manual attach is still possible.)

As an alternative to running from a share, you can use the Visual Studio 2005 Remote Debugger CD to install the necessary remote debugging components on the remote machine. This installation provides access to all remote debugging features.

For certain debugging scenarios, you must install additional components.

To install remote debugging components (non-SQL Server 2005)

  1. The remote debugger is available on the last disc of your Visual Studio 2005 installation set. Insert this disc on the remote machine. For example, if you have four discs in your installation set, insert disc four on the remote machine. If you have a DVD instead of a CD, insert the DVD.

  2. In Windows Explorer, open the CD/DVD. Locate the Remote Debugger folder (on the CD) or vs/Remote Debugger (on the DVD).

  3. In the Remote Debugger folder, open the subfolder that matches your platform (x86, x64, or IA64).

  4. Start the copy of rdbgsetup.exe located in that subfolder and follow the instructions to complete setup.

    If you prefer, you can install the remote debugging components by copying the files manually. See Remote Debugging Components for a list of required components and their install locations. Visual Studio includes separate versions of Remote Debugging Monitor for 32-bit and 64-bit platforms. If you use rdbgsetup.exe, the Remote Components Setup will install the correct version of Remote Debugging Monitor automatically. If you choose to copy the files manually, you need to make sure you have copied the proper version.

  5. Once you have installed the remote debugging components, you need to make sure you have the required permissions to debug a program on the remote machine. See Remote Debugging Permissions for a list of required permissions.

    When you have installed the remote debugging components and have the proper permissions, you can begin remote debugging.

To install remote debugging components on a SQL Server 2005 machine

  1. The install program is already loaded on the SQL Server 2005 machine. Locate the rdbgsetup.exe program, normally in the <sql server install dir>\90\Shared directory.

  2. Double click it to run it. When done, msvsmon.exe (the Remote Debugging Monitor) is installed.

  3. Once you have installed the remote debugging components, you need to make sure you have the required permissions to debug a program on the remote machine. See Remote Debugging Permissions for a list of required permissions.

    When you have installed the remote debugging components and have the proper permissions, you can begin remote debugging.

To Start Remote Debugging

  1. Make sure you have the necessary remote debugging permissions on the remote machine. For more information, see Remote Debugging Permissions.

  2. If you aren't debugging SQL, make sure you are running the Remote Debugging Monitor on the remote machine. For more information, see How to: Run the Remote Debugging Monitor. When debugging SQL, the Remote Debugging Monitor will launch automatically during debugging.

  3. Launch Visual Studio on the debugger host.

    Use Visual Studio to attach to a program you want to debug on the remote machine or launch a program you want to debug on the remote machine. For more information, see How to: Attach to a Running Process.

Enabling Web Server Debugging on Windows XP Service Pack 2

Windows XP Service Pack 2 provides enhanced security. To enable Web server debugging on Windows XP Service Pack 2, you must perform the following additional steps on the web server host machine. Administrator privileges are required.

To enable Web server debugging on Windows XP Service Pack 2

  1. Open the Control Panel and double-click the Security Center icon.

  2. Under Manage Security Settings For, click Windows Firewall.

  3. In the Windows Firewall window, click the Exceptions tab, and then click the Add Port button.

    Steps 2-5 open the TCP 80 port, which needs to be opened for ASP.NET, ASP, and ATL Server debugging.

  4. In the Add a Port dialog box:

    1. For Name, type a description such as TCP 80 port.

    2. For Port Number, type 80.

    3. For Protocol, select TCP.

    4. (Optional) Press the Change Scope button. In the Change Scope window, select My network (subnet) only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

    5. Click OK to close the Change Scope dialog box (if you opened it in Step d).

  5. Click OK to close Add a Port dialog box.

  6. Click OK to close the Windows Firewall dialog box.

Manually Configuring the Windows XP Service Pack 2 Firewall for Remote Debugging

Because of Windows XP Service Pack 2 enhanced security features, remote debugging on Windows XP SP2 platforms requires some additional steps to configure the Windows Firewall. These steps are performed automatically when you run the remote debugger for the first time. If manual setup is necessary for any reason, follow the steps in this section.

If the Windows Firewall is off, no firewall configuration is necessary.

If the Windows Firewall is on, a few ports must be opened and permissions must be granted to Visual Studio and other executables involved in the remote debugging. The Windows Firewall must not be in Shielded mode.

Caution noteCaution

Configuring the Windows Firewall to allow remote debugging may allow other users to gain remote access. You can restrict this access to machines on your local subnet, which will limit the security risk.

To configure the Visual Studio host machine

  1. From the Start menu, click Control Panel.

  2. In the Control Panel window, click Network and Internet Connections.

  3. In the Network and Internet Connections window, click Change Windows Firewall settings.

  4. In the Internet Connection Firewall window, click the Exceptions tab.

  5. On the Exceptions tab, click the Add Port button.

  6. Open TCP port 135 (used by DCOM to communicate with remote machines) by doing the following.

    1. In the Permissions dialog box, select Specify a port.

    2. Under Specify a port:

    • For Protocol, select TCP.

    • For Port Number, type 135.

    • For Description, type a description (such as remote debugging DCOM).

    • (Optional) For scope, select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

    1. Click OK to close the Permissions dialog box.
  7. If your domain policy requires network communication to be done through IPSec, do this step, otherwise skip it.

    1. Open UDP port 4500 (used for IP security) by repeating the prior step, substituting UDP for the Protocol, and 4500 for the Port Number.

    2. Open UDP port 500 (used for IP security) the same way, substituting UDP for the Protocol, and 500 for the Port Number

  8. Add Devenv.exe (the Microsoft Visual Studio development environment) to the SP2 application security Exception list, enabling it to dynamically open ports at runtime.

    1. Click Add program.

    2. In the Add program dialog box, click the Browse button.

    3. In the Browse dialog box, navigate to where devenv.exe is located (normally SystemDrive:\Program Files\Microsoft Visual Studio 8 Common7\IDE). Select devenv.exe.

    4. Click OK to close the Browse dialog box.

    5. (Optional) Press the Change Scope button. In the Change Scope window, select My network (subnet) only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

    6. Click OK to close the Change Scope dialog box (if you opened it in Step e).

    7. Click OK to close the Select a program dialog box.

  9. Click OK to close Internet Connection Firewall.

To configure the remote machine

  1. From the Start menu, choose Control Panel.

  2. In the Control Panel window (Category view), click Network and Internet Connections.

  3. In the Network and Internet Connections window, click Change Windows firewall settings.

  4. In the Internet Connection Firewall window, click the Exceptions tab.

  5. On the Exceptions tab, click the Add button.

    Steps 6-8 open the TCP 135 port, which is used by DCOM to communicate with remote machines.

  6. In the Permissions dialog box, select Specify a port.

  7. Under Specify a port:

    1. For Protocol, select TCP.

    2. For Port Number, type 135.

    3. For Description, type a description (such as remote debugging DCOM).

    4. (Optional) For scope, select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

  8. Click OK to close the Permissions dialog box.

    Steps 9-16 open the UDP 4500 and UDP 500 ports, which are used for IP security. If your domain policy requires network communication to be done through IPSec, you must open these ports. If your domain policy does not require IPSec, you can skip steps 9-16.

  9. Click the Add button again.

  10. In the Permissions dialog box, select Specify a port.

  11. Under Specify a port:

    1. For Protocol, select UDP.

    2. For Port Number, type 4500.

    3. For Description, type a description (such as UDP 4500 port).

    4. (Optional) For scope, select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

  12. Click OK to close the Permissions dialog box.

  13. Click the Add button once again.

  14. In the Permissions dialog box, select Specify a port.

  15. Under Specify a port:

    1. For Protocol, select UDP.

    2. For Port Number, type 500.

    3. For Description, type a description (such as UDP 500 port).

  16. (Optional) For scope, select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

    Steps 17-21 open ports necessary for file and print sharing.

  17. In the Programs and Services group, select File and Print Sharing.

  18. Click the Edit button.

  19. In the Permissions dialog box, select the following ports: TCP 139, TCP 445, UDP 137, and UDP 138.

  20. (Optional) For each port, select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

  21. Click OK.

    Steps 22-28 add msvsmon to the SP2 Exception list, enabling it to dynamically open ports at run time.

  22. Click the Add button once again.

  23. Click Select a program.

  24. Click the Browse button.

  25. In the Browse dialog box, navigate to where Msvsmon.exe is located, which will be one of the following directories:

    Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86

    Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x64

    Install path \Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\ia64

  26. Click OK to close the Browse dialog box.

  27. Type a description in the Description box.

  28. (Optional) Select Local Subnet Only. This limits access to the firewall hole you are opening to machines on the local subnet. Use this option if possible.

  29. Click OK to close the Select a program dialog box.

  30. Click OK to close Internet Connection Firewall.

Remote Debugging to a Windows 95/98/Me Machine

To remote debug from a Windows XP SP2 machine with the Windows firewall enabled to a Windows 95/98/Me machine, you much use dcomcnfg to enable Remote Access for Anonymous Logon.

To enable Remote Access for Anonymous Logon

  1. From the Windows command prompt, run dcomcnfg:

    C:\WINDOWS\System32\dcomcnfg

  2. In the Component Services window, expand the Component Services/Computers node.

  3. Under Component Services/Computers, right-click on My Computer and choose Properties from the shortcut menu.

  4. In the My Computer Properties window, click the COM Security tab.

  5. Under Access Permissions, click the Edit Limits button.

  6. Select Anonymous Logon from the top list.

  7. Select the Remote Access checkbox from the bottom list.

  8. Click OK.

  9. Click OK.

See Also

Tasks

Remote Debugging Errors and Troubleshooting

Concepts

Just-In-Time Debugging

Other Resources

Remote Debugging Setup