次の方法で共有


Set Up Remote Debugging for a Visual Studio Project

You might want to debug a Windows desktop project that is built locally and then run the executable on a remote computer. This topic explains how to change your local project settings to run the app on a remote computer. C++ projects are automatically deployed to the remote machine. You will need to manually deploy .NET Framework executables.

Note

To setup Windows Store projects for debugging on a remote device, see Run Windows Store apps on a remote machine from Visual Studio

These examples assume that the Visual Studio Remote Debugging Monitor has already been set up on the remote computer. See Remote Debugging and Diagnostics.

The topic contains these examples:

Set up a Visual C++ project

Set up a Visual C#/Visual Basic project

Set up a Visual C++ project

The procedure shown here assumes that you have an MFC project, MyMfc, built on computer local1. You want to run the application MyMfc.exe on computer remote1 in the c:\RemoteTemp folder, and then debug by using the Visual Studio debugger on computer local1. Additionally, you want to copy the file c:\Data\MyMfcData.txt to the remote computer.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or software edition. To change your settings, select Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

To prepare the remote computer

To prepare the Visual Studio computer

  1. In the Solution Explorer, right-click the C++ project and select Properties.

  2. In the Property Pages dialog box, expand the Configuration Properties node and choose Debugging. In the Debugger to launch dropdown, select Remote Windows Debugger.

    MyMfc project debugging property page

  3. Make the following changes to the properties:

    Setting

    Change

    Remote Command

    Type c:\remotetemp\mymfc.exe.

    Working Directory

    Change to c:\remotetemp.

    Remote Server Name

    Type remote1.

    Connection

    Make sure it is set to Remote with Windows Authentication.

    Debugger Type

    Change from Auto to Native Only, because you know you are debugging native code.

    Deployment Directory

    Change to c:\remotetemp.

    Additional Files to Deploy

    Change to c:\data\mymfcdata.txt.

  4. On the toolbar, open the Solution Configuration drop-down menu, and choose Configuration Manager.

  5. For the Debug configuration, select the Deploy check box.

    Configuration Manager dialog box

  6. On the Debug menu, select Start Debugging and begin debugging.

    Tip

    The Debug command automatically deploys (copies) the project output and additional files to the remote computer. You can deploy the files as a separate step. In Solution Explorer, open the context menu for MyMfc, and then choose Deploy.

To deploy additional files to the remote computer

  1. (Optional) Create a project folder for the additional file. Select the project in Solution Explorer. On the context menu, choose Add, New Folder. Copy the data file to the new folder.

  2. Add the file to your Visual Studio project. Select a project directory in Solution Explorer. On the context menu, choose Add, Add Existing Item and select the file.

  3. In Solution Explorer, select the file and choose Properties.

    Data file properties

  4. Select Copy always from the Copy to Output Directory list.

Set up a Visual C#/Visual Basic project

The debugger cannot deploy your Visual C# or Visual Basic desktop app to a remote machine. But you can debug the app on a remote machine by using the following procedures.

The procedures shown here assume that you have a WPF app project, MyWpf, built on computer local1. The Debug version of the app is created in the folder C:\Projects\MyWPF\MyWPF\bin\Debug as MyWpf.exe. You want to run the app on computer remote1, and then debug by using the Visual Studio debugger on computer local1.

To prepare the Visual Studio computer

  1. Open the MyWpf project in Visual Studio.

  2. In the Solution Explorer, right-click the project node and select Properties.

  3. On the MyWpf properties page, choose Debug.

    Debug project property page

  4. Make sure the Working directory text box is empty.

  5. Choose Use remote machine, and type remote1 in the text box.

  6. (Optional) Under Debugger Type, select Mixed mode to explicitly enable debugging of both managed and unmanaged code.

  7. Build the app.

To prepare the remote computer

  1. Install and start the Visual Studio Remote Debugger on remote1. See Set Up the Remote Tools on the Device and Start the Remote Debugging Monitor

  2. Create a folder on remote1 that is the same path as the Debug folder on local1: C:\Projects\MyWPF\MyWPF\bin\Debug.

  3. Copy MyWPF.exe from local1 to remote1

To start debugging on the remote computer

  • In Visual Studio on local1, choose Debug / Start Debugging.