In Windows Workflow Foundation, you have two different ways of adding runtime services to the Workflow Engine:

  • Through code, by using the AddService() method of the WorkflowRuntime class
  • Through the application configuration file, by adding an entry to the tag.

The latter is possible not only for the default services built into WF, like the SqlWorkflowPersistenceService, but also for your own ones; you just have to make sure you specify the correct type.

You might have noticed that some of the service take extra parameters on the configuration file. For example, for the SqlWorkflowPersistenceService entry you can configure parameters like the ConnectionString, IsTransactional and so on.

What may not be so obvious is that you can do the same thing for your own services and it's very easy! All you have to do is provide a constructor to your service class that takes a NameValueCollection as an argument; this collection will then have any named parameters that were included in the configuration entry. So, to keep in mind:

  1. Add your service to the configuration entry; each parameter is added as an attribute in the corresponding tag. For example:
  2. Add alternate constructor to your service class with a NameValueCollection argument
  3. Extract named parameters from the NameValueCollection as needed to initialize your runtime service.


Tomas Restrepo

Software developer located in Colombia.