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)
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.
In Windows Explorer, open the CD/DVD. Locate the
Remote Debugger
folder (on the CD) orvs/Remote Debugger
(on the DVD).In the Remote Debugger folder, open the subfolder that matches your platform (x86, x64, or IA64).
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.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
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.Double click it to run it. When done,
msvsmon.exe
(the Remote Debugging Monitor) is installed.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
Make sure you have the necessary remote debugging permissions on the remote machine. For more information, see Remote Debugging Permissions.
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.
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
Open the Control Panel and double-click the Security Center icon.
Under Manage Security Settings For, click Windows Firewall.
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.
In the Add a Port dialog box:
For Name, type a description such as TCP 80 port.
For Port Number, type 80.
For Protocol, select TCP.
(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.
Click OK to close the Change Scope dialog box (if you opened it in Step d).
Click OK to close Add a Port dialog box.
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 |
---|
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
From the Start menu, click Control Panel.
In the Control Panel window, click Network and Internet Connections.
In the Network and Internet Connections window, click Change Windows Firewall settings.
In the Internet Connection Firewall window, click the Exceptions tab.
On the Exceptions tab, click the Add Port button.
Open TCP port 135 (used by DCOM to communicate with remote machines) by doing the following.
In the Permissions dialog box, select Specify a port.
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.
- Click OK to close the Permissions dialog box.
If your domain policy requires network communication to be done through IPSec, do this step, otherwise skip it.
Open UDP port 4500 (used for IP security) by repeating the prior step, substituting UDP for the Protocol, and 4500 for the Port Number.
Open UDP port 500 (used for IP security) the same way, substituting UDP for the Protocol, and 500 for the Port Number
Add Devenv.exe (the Microsoft Visual Studio development environment) to the SP2 application security Exception list, enabling it to dynamically open ports at runtime.
Click Add program.
In the Add program dialog box, click the Browse button.
In the Browse dialog box, navigate to where
devenv.exe
is located (normally SystemDrive:\Program Files\Microsoft Visual Studio 8 Common7\IDE). Selectdevenv.exe
.Click OK to close the Browse dialog box.
(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.
Click OK to close the Change Scope dialog box (if you opened it in Step e).
Click OK to close the Select a program dialog box.
Click OK to close Internet Connection Firewall.
To configure the remote machine
From the Start menu, choose Control Panel.
In the Control Panel window (Category view), click Network and Internet Connections.
In the Network and Internet Connections window, click Change Windows firewall settings.
In the Internet Connection Firewall window, click the Exceptions tab.
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.
In the Permissions dialog box, select Specify a port.
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.
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.
Click the Add button again.
In the Permissions dialog box, select Specify a port.
Under Specify a port:
For Protocol, select UDP.
For Port Number, type 4500.
For Description, type a description (such as UDP 4500 port).
(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.
Click OK to close the Permissions dialog box.
Click the Add button once again.
In the Permissions dialog box, select Specify a port.
Under Specify a port:
For Protocol, select UDP.
For Port Number, type 500.
For Description, type a description (such as UDP 500 port).
(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.
In the Programs and Services group, select File and Print Sharing.
Click the Edit button.
In the Permissions dialog box, select the following ports: TCP 139, TCP 445, UDP 137, and UDP 138.
(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.
Click OK.
Steps 22-28 add
msvsmon
to the SP2 Exception list, enabling it to dynamically open ports at run time.Click the Add button once again.
Click Select a program.
Click the Browse button.
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
Click OK to close the Browse dialog box.
Type a description in the Description box.
(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.
Click OK to close the Select a program dialog box.
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
From the Windows command prompt, run
dcomcnfg
:C:\WINDOWS\System32\dcomcnfg
In the Component Services window, expand the Component Services/Computers node.
Under Component Services/Computers, right-click on My Computer and choose Properties from the shortcut menu.
In the My Computer Properties window, click the COM Security tab.
Under Access Permissions, click the Edit Limits button.
Select Anonymous Logon from the top list.
Select the Remote Access checkbox from the bottom list.
Click OK.
Click OK.
See Also
Tasks
Remote Debugging Errors and Troubleshooting