How to self-host WCF
Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen
Use the following methods to self-host your WCF service in any .NET application:
- Create a method to start the service, as shown in the following code example
// Host the service within the application.
public static void Main()
// Create a ServiceHost for the CalculatorService type.
using (ServiceHost serviceHost =
// Open the ServiceHost to create listeners // and start listening for messages.
- In the self-hosted case, you must specify the base address in your config file.