workflow-foundation-4workflowservice

How can one inject initialization steps into a workflow service?


I am writing a WF4 service and I need to perform some initialization (e.g. initializing log4net). In a normal service, I would just modify global.asax but there is no such file in the WF4 service. Where then do I place this initialization?

This must be a simple matter but I cannot find any answers here on SO or elsewhere so far. Sigh.


Solution

  • In most cases I'd just use a custom activity at the very beginning of the workflow that does the initialization.

    For more elaborate scenarios you can take a look at System.ServiceModel.Activities.Activation.WorkflowServiceHostFactory.

    A blog post with a usage example can be found here: http://blogs.msdn.com/b/endpoint/archive/2011/04/27/how-to-create-a-wf4-workflowservicehostfactory-for-appfabric-auto-start.aspx