Specifying a dedicated service instance for a singleton service

Normally, when hosting a WCF service, we only need to specify the service type in the ServiceHost and the runtime will help create the service instance internally, according to the InstanceContextMode we apply on the service class. This makes hosting a WCF service quite simple and convenient; the service developers do not need to know when and how the runtime creates the service instance. However, in some cases, it is useful and necessary to let the developer control when and how the service instance is created.

Getting ready

Singleton is one of the popular design patterns. This pattern can help design a class that will expose one and only one instance of the class over the entire lifecycle ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.