Redigera

Dela via


Remote Debugging

You can debug a Visual Studio application that has been deployed on a different computer. To do so, you use the Visual Studio remote debugger.

For in-depth instructions on remote debugging, see these topics.

Scenario Link
Azure App Service Remote debug ASP.NET Core on Azure or, for Visual Studio Enterprise, the Snapshot Debugger
Azure VM Remote debug ASP.NET on an Azure VM
Azure Service Fabric Debug an Azure Service Fabric application
ASP.NET Remote debug ASP.NET Core or Remote Debug ASP.NET
C# or Visual Basic Remote debug a C# or Visual Basic project
C++ Remote debug a C++ project
Docker Attach to a process running in a Docker container
Linux Debug .NET Core on Linux using SSH by attaching to a process
Universal Windows Apps (UWP) Run UWP apps on a remote machine or Debug an installed app package

If you just want to download and install the remote debugger and don't need any additional instructions for your scenario, follow the steps in this article.

Download and Install the remote tools

On the remote device or server that you want to debug on, rather than the Visual Studio machine, download and install the correct version of the remote tools from the links in the following table.

  • Download the most recent update of the remote tools for your version of Visual Studio. Earlier remote tools versions aren't compatible with later Visual Studio versions. (For example, if you're using Visual Studio 2019, download the latest update of the remote tools for Visual Studio 2019. In this scenario, don't download the remote tools for Visual Studio 2022.)
  • Download the remote tools with the same architecture as the machine you're installing them on. For example, if you want to debug x86 applications on a remote computer running an x64 operating system, install the x64 remote tools. To debug x86, ARM, or x64 applications on an ARM64 operating system, install the ARM64 remote tools.
Version Link Notes
Visual Studio 2022 Remote tools Compatible with all Visual Studio 2022 versions. Download the version matching your device operating system (x86, x64 (AMD64), or ARM64). On older versions of Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2019 Remote tools Remote tools for Visual Studio 2019 are available from My.VisualStudio.com. If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. Download the version matching your device operating system (x86, x64 (AMD64), or ARM64). On older versions of Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2017 Remote tools Remote tools for Visual Studio 2017 are available from My.VisualStudio.com. If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. Download the version matching your device operating system (x86, x64 (AMD64), or ARM64). On Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2015 Remote tools Remote tools for Visual Studio 2015 are available from My.VisualStudio.com. If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. On Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2013 Remote tools Download page in Visual Studio 2013 documentation
Visual Studio 2012 Remote tools Download page in Visual Studio 2012 documentation
Version Link Notes
Visual Studio 2019 Remote tools Compatible with all Visual Studio 2019 versions. Download the version matching your device operating system (x86, x64 (AMD64), or ARM64). On Windows Server, see Unblock the file download for help with downloading the remote tools. For the most recent version of the remote tools, open the Visual Studio 2022 doc.
Visual Studio 2017 Remote tools Compatible with all Visual Studio 2017 versions. Download the version matching your device operating system (x86, x64 (AMD64), or ARM64). On Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2015 Remote tools Remote tools for Visual Studio 2015 are available from My.VisualStudio.com. If prompted, join the free Visual Studio Dev Essentials program, or sign in with your Visual Studio subscription ID. On Windows Server, see Unblock the file download for help with downloading the remote tools.
Visual Studio 2013 Remote tools Download page in Visual Studio 2013 documentation
Visual Studio 2012 Remote tools Download page in Visual Studio 2012 documentation

You can run the remote debugger by copying msvsmon.exe to the remote computer, rather than installing the remote tools. However, the Remote Debugger Configuration Wizard (rdbgwiz.exe) is available only when you install the remote tools. You may need to use the wizard for configuration if you want to run the remote debugger as a service. For more information, see (Optional) Configure the remote debugger as a service.

Note

  • To debug Windows 10 or later apps on ARM devices, use ARM64, which is available with the latest version of the remote tools.
  • To debug Windows 10 apps on Windows RT devices, use ARM, which is available only in the Visual Studio 2015 remote tools download.
  • To debug x64 apps on an ARM64 operating system, run the x64 msvsmon.exe that is installed with the ARM64 remote tools.

Requirements

Supported Operating Systems

The remote computer must be running one of the following operating systems:

  • Windows 11

  • Windows 10 (not phone)

  • Windows 8 or 8.1 (not phone)

  • Windows 7 Service Pack 1

  • Windows Server 2016

  • Windows Server 2012 or Windows Server 2012 R2

  • Windows Server 2008 Service Pack 2, Windows Server 2008 R2 Service Pack 1

Note

Windows Phone requires a USB connection to debug (it does not require the remote tools).

Supported Hardware Configurations

  • 1.6 GHz or faster processor

  • 1 GB of RAM (1.5 GB if running on a virtual machine)

  • 1 GB of available hard disk space

  • 5400-RPM hard drive

  • DirectX 9-capable video card running at 1024 x 768 or higher display resolution

Network configuration

The remote computer and the Visual Studio computer must be connected over a network, workgroup, or homegroup, or else connected directly through an Ethernet cable. Debugging between two computers connected through a proxy isn't supported. Debugging over a high latency or low bandwidth connection, such as dialup Internet, or over the Internet across countries/regions isn't recommended and may fail or be unacceptably slow.

(Optional) To run the remote debugger from a file share

You can find the remote debugger (msvsmon.exe) on a computer with Visual Studio Community, Professional, or Enterprise already installed. For some scenarios, the easiest way to set up remote debugging is to run the remote debugger (msvsmon.exe) from a file share. For usage limitations, see the remote debugger's Help page (Help > Usage in the remote debugger).

  1. Find msvsmon.exe in the directory matching your version of Visual Studio:

    Program Files\Microsoft Visual Studio 17.0\Common7\IDE\Remote Debugger\x64\msvsmon.exe

    Program Files\Microsoft Visual Studio 17.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe

    Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Remote Debugger\x64\msvsmon.exe

    Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Remote Debugger\x86\msvsmon.exe

  2. Share the Remote Debugger folder on the Visual Studio computer.

  3. On the remote computer, run msvsmon.exe from the shared folder. Follow the setup instructions.

Tip

For command line installation and command line reference, see the Help page for msvsmon.exe by typing msvsmon.exe /? in the command line on the computer with Visual Studio installed (or go to Help > Usage in the remote debugger).

Set up the remote debugger

  1. On the remote computer, find and start the Remote Debugger from the Start menu.

    If you don't have administrative permissions on the remote computer, right-click the Remote Debugger app and select Run as administrator. Otherwise, just start it normally.

    If you are planning to attach to a process which is running as an administrator, or is running under a different user account (such as IIS), right-click the Remote Debugger app and select Run as administrator. For more information, see Run the remote debugger as an administrator.

  2. The first time you start the remote debugger (or before you have configured it), the Remote Debugging Configuration wizard appears.

    In most scenarios, choose Next until you get to the Configure the Windows Firewall page of the wizard.

    Screenshot of remote debugger configuration.

    Screenshot of remote debugger configuration.

    If the Windows Web Services API is not installed, which happens only on Windows Server 2008 R2, select the Install button.

  3. Select at least one network type you want to use the remote tools on. If the computers are connected through a domain, you must choose the first item. If the computers are connected through a workgroup or homegroup, choose the second or third item as appropriate.

    Next, select Finish to start the remote debugger.

    Next, select Configure remote debugging to start the remote debugger.

  4. When configuration is complete, the Remote Debugger window appears.

    Screenshot of remote debugger window

    Screenshot of remote debugger window

    The remote debugger is now waiting for a connection. Use the server name and port number shown to set the remote connection configuration in Visual Studio.

To stop the remote debugger, select File > Exit. You can restart it from the Start menu, or from the command line:

<Remote debugger installation directory>\msvsmon.exe

Configure the remote debugger

You can change some aspects of the configuration of the remote debugger after you have started it for the first time.

  • If you need to add permissions for other users to connect to the remote debugger, choose Tools > Permissions. You must have administrator privileges to grant or deny permissions.

    Important

    You can run the remote debugger under a user account that differs from the user account you are using on the Visual Studio computer, but you must add the different user account to the remote debugger's permissions.

    Alternatively, you can start the remote debugger from the command line with the /allow <username> parameter: msvsmon /allow <username@computer>.

  • If you need to change the Authentication mode or the port number, or specify a timeout value for the remote tools: choose Tools > Options.

    For a listing of the port numbers used by default, see Remote Debugger Port Assignments.

    Warning

    You can choose to run the remote tools in No Authentication mode, but this mode is strongly discouraged. There is no network security when you run in this mode. Choose the No Authentication mode only if you are sure that the network is not at risk from malicious or hostile traffic.

(Optional) Configure the remote debugger as a service

For debugging in ASP.NET and other server environments, you must either run the remote debugger as an Administrator or, if you want it always running, run the remote debugger as a service.

If you want to configure the remote debugger as a service, follow these steps.

  1. Find the Remote Debugger Configuration Wizard (rdbgwiz.exe). (This is a separate application from the Remote Debugger.) It is available only when you install the remote tools. It is not installed with Visual Studio.

  2. Start running the configuration wizard. When the first page comes up, click Next.

  3. Check the Run the Visual Studio Remote Debugger as a service checkbox.

  4. Add the name of the user account and password.

    You may need to add the Log on as a service user right to this account (Find Local Security Policy (secpol.msc) in the Start page or window (or type secpol at a command prompt). When the window appears, double-click User Rights Assignment, then find Log on as a service in the right pane. Double-click it. Add the user account to the Properties window and click OK). Click Next.

  5. Select the type of network that you want the remote tools to communicate with. At least one network type must be selected. If the computers are connected through a domain, you should choose the first item. If the computers are connected through a workgroup or homegroup, you should choose the second or third items. Click Next.

  6. If the service can be started, you will see You have successfully completed the Visual Studio Remote Debugger Configuration Wizard. If the service cannot be started, you will see Failed to complete the Visual Studio Remote Debugger Configuration Wizard. The page also gives some tips to follow to get the service to start.

  7. Click Finish.

    At this point the remote debugger is running as a service. You can verify this by going to Control Panel > Services and looking for Visual Studio Remote Debugger.

    You can stop and start the remote debugger service from Control Panel > Services.

Set up debugging with remote symbols

You should be able to debug your code with the symbols you generate on the Visual Studio computer. The performance of the remote debugger is much better when you use local symbols. If you must use remote symbols, you need to tell the remote debugging monitor to look for symbols on the remote machine.

You can use the following msvsmon command-line switch to use remote symbols for managed code: Msvsmon /FallbackLoadRemoteManagedPdbs

For more information, please see the remote debugging help (press F1 in the remote debugger window, or click Help > Usage).