Zulfiqar's weblog

Architecture, security & random .Net

Initializing Auto-Start WCF/Workflow Services

Posted by zamd on November 26, 2010

AppFabric AutoStart feature is built on top of IIS 7.5 AutoStart feature. IIS 7.5 provides an extensibility point where you can specify your custom initialization providers which will be executed as part of application start-up and gives you the ability to perform costly initialization. For example, pre-populating an AppFabric cache.

Windows Server AppFabric uses this extensibility point to implement the AutoStart feature for WCF & Workflow Services (XAMLX). As part of AppFabric installation, it registers a custom AutoStartProvider which is responsible for activating all the services configured for AutoStart. Here is a simple flow diagram…

imageActivation of WCF/Workflow Services results in calling the ServiceHostFactory associated with the service to return an instance of the ServiceHost which would ultimately host the service and make it available to the clients. This behaviour opens up an option where you could put your costly initialization inside the custom ServiceHostFactory directly rather than using the IIS 7.5 extensibility. CreateServiceHost method of your custom factory will be invoked as soon as AppFabric auto starts your service.

public class CustomXamlxHostFactory : WorkflowServiceHostFactory     
      protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)


            var host = base.CreateWorkflowServiceHost(service, baseAddresses);

            // Initialization logic: Populate AppFabric cache etc..

            return host;



In .NET 4.0, a custom ServiceHostFactory can be easily associated with a service using the <serviceActivations> element in the web.config.


Check out my earlier post for additional details…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: