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
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

  1. Install Visual Studio 2005 on the host machine

    Visual Studio 2005 Beta 1 Refresh with Visual Studio 2005 Team System

  2. Install Visual Studio 2005 Remote Debugging Components on the remote machine

  3. Install the application to debug (along with the related PDB and other DLLs and necessary files) on the remote machine

    • Map a drive to the remote machine (e.g. “G:”)
    • 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
    • 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
    • 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...

Click Permissions... to configure Remote Debugging Permissions

Click Advanced... to configure any special privileges required by the debugging user account

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

The following table describes the privileges required to debug the various types of code supported by

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

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…

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.).