Self-Hosting Your Service

The most flexible and easiest way to host WCF services is by self-hosting. To be able to self-host your services, you have to meet two requirements. First, you need the WCF runtime; second, you need a managed .NET application in which you can host ServiceHost. It is your own responsibility to write the code that starts and stops the host.

The following are the advantages of self-hosting:

Is easy to use

With only a few lines of code you have your service running.

Is flexible

You can easily control the lifetime of your services through the Open() and Close() methods of ServiceHost<T>.

Is easy to debug

Debugging WCF services that are hosted in a self-hosted environment provides a familiar way of debugging, without having ...

Get Pro WCF: Practical Microsoft SOA Implementation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.