The example is bizarre and probably buggy.
It overrides "ServiceHostBase CreateServiceHost(string service, Uri[] baseAddresses)" and returns a ServiceHost instance, rather than the DerivedHost instance that one would expect.
In fact there is in most cases no need to override this method: the base implementation calls "CreateServiceHost( Type t, Uri[] baseAddresses)", which does return a DerivedHost instance.
A more sensible implementation would be:
publicclass DerivedFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
{
returnnew DerivedHost( t, baseAddresses );
}
}