+

Search Tips | Advanced Search

Building WCF service applications using method 1: Self-hosting administratively using an application configuration file

Having created an application configuration file, open an instance of the service and add the specified code to our application.


Before you begin

Create or edit an application configuration file for the service, as described in: Creating a WCF custom channel administratively by supplying binding and endpoint information in an application configuration file


About this task

  1. Instantiate and open an instance of the service in the service host. The service type must be the same as the service type specified in the service configuration file.
  2. Add the following code to our application:
    ServiceHost service = new ServiceHost(typeof(MyService));
    service.Open();
    ...
    service.Close();