We are running WCF services with net.tcp bindings in IIS 7.5, so we make use of non-HTTP activations and WAS Hosting. We are have created a custom service host factory for each service, which is derived from AutofacServiceHostFactory
I was recently doing some maintenance on the services (switching to use NuGet packages upgrading to the latest versions, etc). I happened to notice that the wiki article for WCF Integration recommends using an override of CreateServiceHost(string constructorString, Uri[] baseAddresses) and building up the container there before calling the base implementation.
Our ServiceHostFactories have been using a static constructor to do the same thing. I’m wondering if I should switch. Is there a reason a static constructor is a bad idea? If using the overrides, we need to override any of the other overloads for CreateServiceHost().
Thanks for the help!
It appears that the recommendation has changed again to use the
AppStart.AppInitialize()to register the dependencies and build the container in a protocol agnostic faction. That’s what we’re doing now.Autofac Wiki
Referenced article