Visual Studio 2005 Remote Debugging
The purpose of this document is to illustrate how to configure and use Visual Studio 2005 for both 32-Bit and 64-Bit remote debugging. This document should be particularly useful for 64-Bit .NET Frameworkwork 2.0 developers because the 64-Bit .NET Framework 2.0 only supports remote debugging from Visual Studio 2005.
The following drawing illustrates the typical remote debugging scenario. First, the application is developed & tested on 32-bit local host computer. Next, the application is cross-compiled for the 64-bit computer. Then, the application is installed and executed on the 64-bit remote computer. Finally, the application is remotely debugged from the 32-bit local host computer.
| 32-bit Host Computer | 64-bit Remote Computer | .gif) | .gif) | | Develop and test code | | | | | | Cross compile for remote computer | | | | Copy executable to remote computer | | | Execute code here | | (Remotely) Debug remaining bugs here | |
|
Install Remote Debugging Components
- Install Visual Studio 2005 on the host machine
Get Visual Studio 2005 Beta 1 Refresh with Visual Studio 2005 Team System
- Install Visual Studio 2005 Remote Debugging Components on the remote machine
- Install the application to debug (along with the related PDB and other DLLs and necessary files) on the remote machine
To install the application on the remote machine as part of the build process: - Map a drive to the remote machine (e.g. “G:”)
.gif)
- Start Visual Studio 2005 by navigating to Start | All Programs | Microsoft Visual Studio 2005 Beta | Microsoft Visual Studio 2005
- Open the project to debug by selecting menu-command File | Open | Project/Solution
- Once, the project is loaded, select menu-command Project | Properties
.gif)
- In the tree view in the left pan, select Build Events | Post-Build Event
- Select Command Line and enter the commands for installing the application on the remote machine
E.g. xcopy $(TargetDir)*.* G:\$(OutDir)\*.* /E /Y
NOTE: The directory structure of the remote machine must be identical to the directory structure of the host machine.
- Click OK
Start Debugging
- Start Remote Debug Monitor on the remote machine by navigating to Start | All Programs | Microsoft Visual Studio 2005 Beta | Visual Studio Tools | Remote Debugging Monitor
- Configure Remote Debugging Monitor by selecting menu-command Tools | Options...
.gif)
- Click Permissions... to configure Remote Debugging Permissions
.gif)
- Click Advanced... to configure any special privileges required by the debugging user account
.gif)
The following table describes the privileges required to debug the various types of code supported by Remote Debugging Monitor
| Type of Code Being Debugged | Privilege Required |
|---|
Native Code Debugging (C/C++ only) | No special privileges required (on remote machine) to debug a process running under your own user account. SE_DEBUG_PRIVILEGE required (on remote machine) to debug a process running under a different user account. |
Managed Code Debugging (VB.NET, C#, C++ w/Managed Extensions, VJ#) | No special privileges required (on remote machine) to debug a process running under your own user account. Administrator privilege required (on remote machine) to debug a process running under a different user account. |
TSQL Debugging (Versions prior to SQL Server 2005) | sp_sdidebug() execution permission to debug on SQL2000 or SQL7 databases |
TSQL Debugging (SQL Server 2005) | Permission to debug the stored procedure(s) |
Managed Code Debugging (SQL Server 2005) | sysadmin privilege required |
.gif)
- Start Visual Studio 2005 on the host machine
- Use Visual Studio 2005 on the host machine to start the application for debugging on the remote machine
- Select menu-command Project | Properties
- In the tree view in the left pan, select Configuration Properties | Debugging
.gif)
- Select Remote Windows Debugger from the drop down
- Configure the debugging information
- Click OK
- Press F5 to start the debugging session
Or
- Use Visual Studio 2005 on the host machine to attach to the (already running) application on the remote machine
- Select menu-command Debug | Attach To Process…
.gif)
- Select the Process To Attach to
- Configure the connection information:
- Transport:
- Smart Device
- Remote (Native only w/no authentication)
- Default (Native or managed w/authentication)
- Qualifier:
- E.g. local server name, remote server name
- Code Type:
- Common Language Runtime
- Microsoft TSQL
- Native
- Auto(detect)
- Click Attach to start the debugging session
The rest of your debugging session should be like a normal debugging session (setting breakpoints, watching variables, etc.).