Partager via


How to: Debug a Self-Hosted WCF Service

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

A self-hosted service is a WCF service that does not run inside IIS, the WCF Service Host, or the ASP.NET Development Server. The easiest way to debug a self-hosted WCF is to configure Visual Studio to launch both client and server when you choose Start Debugging on the Debug menu.

If the WCF service is self-hosting inside or a process that cannot be launched in this manner, such as NT service, you cannot use this method. Instead, you can do one of the following:

  • Manually attach the debugger to the hosting process. For more information, see Attach to Running Processes.

    — or —

  • Start debugging the client, and then step into a call to the service. This requires that you enable debugging in the app.config file. For more information, Limitations on WCF Debugging.

To start both client and host from Visual Studio

  1. Create a Visual Studio solution that contains both the client and server projects.

  2. Configure the solution to start both client and server processes when you choose Start on the Debug menu.

    1. In Solution Explorer, right-click the solution name.

    2. Click Set Startup Projects.

    3. In the Solution <name> Properties dialog box, select Multiple Startup Projects.

    4. In the Multiple Startup Projects grid, on the line that corresponds to the server project, click Action and choose Start.

    5. On the line that corresponds to the client project, click Action and choose Start.

    6. Click OK.

See also