Using a custom ServiceHost
WCF provides a powerful and flexible configuration system that allows service developers or server administrators to configure service endpoints or hosting behaviors, either programmatically or declaratively (in app.config
file). However, sometimes it is useful and important to find a proper means to configure a large amount of services in a common manner instead of manipulating each service individually. In such cases, a quite straightforward way is to create a custom ServiceHost
and make all our service hosted with it.
How to do it...
In this recipe, we will use a DebugServiceHost
(which ensures that IncludeExceptionDetails
is enabled) sample to demonstrate how we can create a custom ServiceHost
and use it to extend a WCF service.
Define a custom
ServiceHost
type.The first and most important thing to do is to create the custom
ServiceHost
type. Any customServiceHost
type must be derived from either theServiceHostBase
orServiceHost
class under theSystem.ServiceModel...