Self-Hosting of WCF services

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




While implementing WCF service, at the end you will have to decide how to host it. In general there two options. Either you host it by yourself (self-hosting) or you host it in the existing host (for example IIS/WAS). This post shows advantages and disadvantages of Self-hosted service.

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 to attach to separate applications that activate your service.
  • Is easy to deploy: In general, deploying simple Windows applications is as easy as xcopy. You don't need any complex deployment scenarios on server farms, and the like, to deploy a simple Windows application that serves as a WCF ServiceHost.
  • Supports all bindings and transports: Self-hosting doesn't limit you to out-of-the-box bindings and transports whatsoever. On Windows XP and Windows Server 2003, IIS limits you to HTTP only.


Disadvantages of Self-Hosting:

  • Limited availability: The service is reachable only when the application is running.
  • Limited features: Self-hosted applications have limited support for high availability, easy manageability, robustness, recoverability, versioning, and deployment scenarios. These scenarios have become a standard in last few years. Such features are provided by the WAS (Windows Activation Service) which is a part of IIS7 (delivered with Vista and Win2008). This hosting mechanism allows you to host the service by using of protocols like MSMQ, HTTP and TCP.

In other words, you shouldn't consider self-hosting for enterprise and production scenarios. Self-hosting is suitable during the development or demonstration phases of your enterprise project. Another suitable example where you would self-host your services is when you want applications on a user desktop to communicate with each other or in a peer-to-peer scenario.

Posted Nov 08 2007, 02:47 PM by Damir Dobric
Filed under:


Same Old Applications wrote Self-Hosting Services
on 11-09-2007 16:13

Damir, in his Self-Hosting of WCF Services , writes about advantages and disadvantages of self-hosting

Vadym wrote re: Self-Hosting of WCF services
on 11-16-2007 16:16

Yes, there are some limitations, however if WCF service is hosted in the Windows Service then "Limited Availability"  is not an issue.

marco wrote re: Self-Hosting of WCF services
on 02-11-2008 17:47

You could easily host the self-hosted WCF service in a windows NT service, and it will be always on.

If you use must use Winows Server 2003, without WAS, the http only binding could be a major limitation, imho.  So, I would not be so strict saying that self-hosting is only for debug.

Damir Dobric wrote re: Self-Hosting of WCF services
on 07-06-2008 15:00

You are right Marco. Unfortunately our problem is not to find a way how to do it, because we already  have several possible ways. I think, that we need at the Microsoft platform the server product or whatever, which is just able to host anything. How about Server which host WCF-services (by using of any possible binding), Workflows, Biztalk orchestrations, Sharepoint Workflows (if it would be then any difference in comparison to native WF ) and event APS.Net and Sliverlight sites?

I hope and wander in the same time that Microsoft is going to do this as a part of Oslo project. is a .Net Community Blog powered by daenet GmbH.