WCF Service Host (WcfSvcHost.exe) - WCF (2024)

  • Article

Windows Communication Foundation (WCF) Service Host (WcfSvcHost.exe) allows you to launch the Visual Studio debugger (F5) to automatically host and test a service you have implemented. You can then test the service using WCF Test Client (WcfTestClient.exe), or your own client, to find and fix any potential errors.

WCF Service Host

WCF Service Host enumerates the services in a WCF service project, loads the project's configuration, and instantiates a host for each service that it finds. The tool is integrated into Visual Studio through the WCF Service template and is invoked when you start to debug your project.

By using WCF Service Host, you can host a WCF service (in a WCF service library project) without writing extra code or committing to a specific host during development.

Note

WCF Service Host does not support Partial Trust. If you want to use a WCF Service in Partial Trust, do not use the WCF Service Library Project template in Visual Studio to build your service. Instead, create a New WebSite in Visual Studio by choosing the WCF Service WebSite template, which can host the service in a WebServer on which WCF Partial Trust is supported.

Project Types hosted by WCF Service Host

WCF Service Host can host the following WCF service library project types: WCF Service Library, Sequential Workflow Service Library, State Machine Workflow Service Library and Syndication Service Library. WCF Service Host can also host those services that can be added to a service library project using the Add Item functionality. This includes WCF Service, WF State Machine Service, WF Sequential Service, XAML WF State Machine Service and XAML WF Sequential Service.

You should note, however, that the tool will not help you to configure a host. For this task, you must manually edit the App.config file. The tool also does not validate user-defined configuration files.

Caution

You should not use WCF Service Host to host services in a production environment, as it was not engineered for this purpose. WCF Service Host does not support the reliability, security, and manageability requirements of such an environment. Instead, use IIS since it provides superior reliability and monitoring features, and is the preferred solution for hosting services. Once development of your services is complete, you should migrate the services from WCF Service Host to IIS.

Scenarios for Using WCF Service Host inside Visual Studio

The following table lists all the parameters in the Command line arguments dialog box, which can be found by right-clicking your project in Solutions Explorer in Visual Studio, selecting Properties, then selecting the Debug tab and clicking Start Project. These parameters are useful in configuring WCF Service Host.

ParameterMeaning
/clientAn optional parameter that specifies the path to an executable to run after the services are hosted. This launches WCF Test Client following hosting.
/clientArgSpecify a string as an argument that is passed to the custom client application.
/?Displays the help text.

Using WCF Test Client

After you create a new WCF service project and press F5 to start the debugger, WCF Service Host starts hosting all the services it finds in your project. WCF Test Client automatically opens and displays a list of service endpoints defined in the configuration file. From the main window, you can test the parameters and invoke your service.

To make sure that WCF Test Client is used, right-click your project in Solutions Explorer in Visual Studio, select Properties, then select the Debug tab. Click Start Project and ensure that the following appears in the Command line arguments dialog box.

/client:WcfTestClient.exe

Using a Custom Client

To use a custom client, right-click your project in Solutions Explorer in Visual Studio, select Properties, then select the Debug tab. Click Start Project and edit the /client parameter in the Command line arguments dialog box to point to your custom client, as indicated in the following example.

/client:"path/CustomClient.exe"

When you press F5 to start the service again, WCF Service Host automatically starts your custom client when you launch the debugger.

You can also use the /clientArg: parameter to specify a string as an argument that is passed to the custom client application, as indicated in the following example.

/client:"path/CustomClient.exe" /clientArg:"arguments that are passed to Client"

For example, if you are using the Syndication Service Library template, you can use the following command line arguments,

/client:iexplore.exe /clientArgs:http://localhost:8731/Design_Time_Addresses/Feed1/

Specifying No Client

To specify that no client will be used after WCF service hosting, right-click your project in Solutions Explorer in Visual Studio, select Properties, then select the Debug tab. Click Start Project and leave the Command line arguments dialog box blank.

Using a Custom Host

To use a custom host, right-click your project in Solutions Explorer in Visual Studio, select Properties, then select the Debug tab. Click Start External Program and enter the full path to the custom host. You can also use the Command line arguments dialog box to specify arguments to be passed to the host.

WCF Service Host User Interface

When you initially invoke WCF Service Host (by pressing F5 inside Visual Studio), the WCF Service Host window automatically opens. When WCF Service Host is running, the program's icon appears in the notification area. Double-click the icon to open the WCF Service Host window

When errors occur during service hosting, WCF Service Host dialog box will open to display relevant information.

The WCF Service Host main window contains two menus:

  • File: Contains the Close and Exit commands. When you click Close, the WCF Service Host dialog box closes, but the services continue to be hosted. When you click Exit, WCF Service Host is also shut down. This also stops all hosted services.

  • Help: Contains the About command that contains version information. It also contains the Help command that can open a help file.

The main WCF Service Host window contains two areas:

  • The first area is Service. It contains a list that displays basic information of all services. The information includes:

    • Service: Lists all the services.

    • Status: Lists the status of the service. Valid values are "Started", "Stopped," and "Error".

    • Metadata Address: Displays the metadata address of the services.

  • The second area is Additional Information. It displays a detailed explanation of the service status when the specific service line is selected in the Service area. If the status is Error, you can view the full error message on the screen.

Stopping WCF Service Host

You can shut down WCF Service Host in the following four ways:

  • Stop the debugging session in Visual Studio.

  • Select Exit from the File menu in the WCF Service Host window.

  • Select Exit from context menu of WCF Service Host tray icon in the system notification area.

  • Exit WCF Test Client if it is being used.

Using Service Host without Administrator privilege

To enable users without administrator privilege to develop WCF services, an ACL (Access Control List) is created for the namespace "http://+:8731/Design_Time_Addresses" during the installation of Visual Studio. The ACL is set to (UI), which includes all interactive users logged on to the machine. Administrators can add or remove users from this ACL, or open additional ports.This ACL enables users to use the WCF Service Auto Host (wcfSvcHost.exe) without granting them administrator privileges.

You can modify access using the netsh.exe tool in Windows Vista under the elevated administrator account. The following is an example of using netsh.exe.

netsh http add urlacl url=http://+:8001/MyService user=<domain>\<user>

For more information on netsh.exe, see "How to Use the Netsh.exe Tool and Command-Line Switches".

See also

  • WCF Test Client (WcfTestClient.exe)
WCF Service Host (WcfSvcHost.exe) - WCF (2024)

FAQs

What is a WCF service host? ›

WCF Service Host enumerates the services in a WCF service project, loads the project's configuration, and instantiates a host for each service that it finds. The tool is integrated into Visual Studio through the WCF Service template and is invoked when you start to debug your project.

How do you check WCF service is running or not? ›

Testing WCF service using Test Client (wcftestclient.exe)
  1. Open Visual Studio command prompt and type wcftestclient then Enter.
  2. After pressing Enter, we get a GUI application of the WCF Test Client.
  3. Select File->Add Service and type the service endpoint url as address and click ok. ...
  4. Double click on Greeting Method.
Feb 14, 2011

How to debug WCF service hosted in IIS? ›

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.

How to debug WCF service with WCF test client? ›

WCF Service Host Starts WCF Test Client with a Single Service. After you create a new WCF service project and press F5 to start the debugger, the WCF Service Host begins to host the service in your project. Then, WCF Test Client opens and displays a list of service endpoints defined in the configuration file.

What are WCF services used for? ›

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

Is it OK to disable service host? ›

Is it ok to disable service host Sysmain? Yes, if SysMain is consuming high CPU usage, you can disable it, but this will disable some automatic programs in the system.

Are WCF services obsolete? ›

Windows Communication Framework (WCF) may be deprecated in . NET 5/6+, but it doesn't mean your applications are going to be left out in the cold. Just like Web Forms and other . NET Framework technologies, your WCF applications will continue to work for a long time.

How do I activate WCF service? ›

Activate Windows Communication Foundation (WCF)
  1. From the Start menu, select Administrative Tools > Server Manager.
  2. Select Add roles and features from the Dashboard.
  3. Select Next twice.
  4. Select Features.
  5. In the Features area, expand the: - . ...
  6. Under WCF Services select: - HTTP Activation.

What is the difference between WCF service and Web service? ›

What is the difference between WCF service and Web service? Web services can only be hosted in IIS, but WCF can be hosted in IIS, Windows activation services, self-hosting, & Windows services. WCF is ideal for developing real-time applications because it is more dependable, quick, and robust than web services.

Can WCF be hosted in IIS? ›

A WCF service that runs in the IIS environment takes full advantage of IIS features, such as process recycling, idle shutdown, process health monitoring, and message-based activation.

How to configure an IIS hosted WCF service with SSL? ›

  1. Open IIS Manager.
  2. Click on your Server node. ...
  3. Here we will use a Self-Signed certificate to keep it simple. ...
  4. Select your site (for example, "SecureSite" here). ...
  5. Add a Site Binding. ...
  6. Verify that your SSL binding is working on "SecureSite" by Browsing to it.
Nov 16, 2018

How do I make my WCF service asynchronous? ›

Implement a service operation asynchronously
  1. In your service contract, declare an asynchronous method pair according to the . ...
  2. Mark the Begin method of the asynchronous method pair with the System. ...
  3. Implement the Begin/End method pair in your service class according to the asynchronous design guidelines.
Sep 14, 2021

How do I access WCF service? ›

With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.

How do I run WCF service from command line? ›

The WCF service can only respond to clients if the Windows service is running. To start the service, right-click it in the SCM and select "Start", or type net start WCFWindowsServiceSample at the command prompt. If you make changes to the service, you must first stop it and uninstall it.

How do I run a local WCF service? ›

To open WCF Test Client, open Developer Command Prompt for Visual Studio and execute WcfTestClient.exe. Select Add Service from the File menu. Type http://localhost:8080/hello into the address box and click OK. Make sure the service is running or else this step fails.

Is WCF service still used? ›

As of the release of . NET 5, WCF is basically deprecated. While it will still work with . NET Framework for years to come, it won't be supported in .

What is the difference between webservice and WCF service? ›

What is the difference between WCF service and Web service? Web services can only be hosted in IIS, but WCF can be hosted in IIS, Windows activation services, self-hosting, & Windows services. WCF is ideal for developing real-time applications because it is more dependable, quick, and robust than web services.

What is service host running on my PC? ›

"Service Host: Storage Service" is a system process in Windows that is responsible for managing storage-related tasks and services. It is a part of the Windows operating system and is essential for handling functions such as disk management, file operations, and storage-related system services.

How do I use WCF service? ›

Consuming WCF Service Hosted in IIS 5/6
  1. Step 1 − Once a service is hosted in IIS, we have to consume it in client applications. ...
  2. Step 2 − Now, we will start creating the Console application using Visual Studio 2008 (Client application).
  3. Step 3 − Add the reference 'System. ...
  4. Step 4 − Create a Proxy class.

Top Articles
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 5724

Rating: 4 / 5 (41 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.