I used to have a HTTP based transport and I bootstrapped my app in Applicaiton_Start.
By bootstrap I mean set up my DI container etc.
I want to change to named pipes but I may want to continue using HTTP on another server.
Can I use the following to bootstrap independent of transport?
I’m hosting inside IIS.
/// <summary>
/// This class needs to reside in the App_Code special ASP.NET folder
/// It also needs to be set with a build action of Content
/// The signature public static void AppInitialize() is recognised by ASP.NET and is
/// always called no matter the binding (HTTP or not)
/// </summary>
public static class AppStart
{
public static void AppInitialize()
{
Bootstrapper.Initialize();
}
}
You need to write a custom ServiceHostFactory along with several other classes.
Rory Primrose has two good blog posts on the topic using Unity.
Unity dependency injection for WCF services – Part 1
Unity dependency injections for WCF services – Part 2