Hosting Quickstart Sample for Windows Workflow Foundation - IIS or NT Service

We just published a WF Hosting Quickstart sample today and it shows a common hosting model for building WF programs and running them in either of:

  • ASP.NET and IIS
  • Your NT Service
  • A Console Host

Okay the third is just a debugging convenience for the second. This sample provides a simple layer that means you don't have any changes to your workflows and your WF Runtime Services whether running on either the first of second type of host. You should think of using this project as a start for building your own hosting environment for Windows Workflow Foundation projects. This joins a collection of other examples of WF Hosting which are also available:

It works with either Visual Studio 2005 or Visual Studio 2008. If you're still on 2005 you will need the .NET Framework 3.0 add-ons for WF.

Here's a simple walkthrough, although the readme in the sample also walks through this.

  1. Open the ZIP file
  2. Open the whitepaper and review it
  3. Open the VSI from the ZIP file – This part requires Visual Studio to be installed. You'll get an error otherwise.
  4. The VSI will prompt to accept installation of the addins and for a simple license
  5. Once this is done start Visual Studio
  6. Create a new project
  7. Choose the Visual C# node

  1. Click okay to create the project
  2. I don't have SQL Server express so I had to attach to the provided sql database and change the web.config and app.config files. This is my new connection string.

    <connectionStrings>

        <add
name="ASPNETWFConnectionString"
connectionString="server=.\SQLEXPRESS;Database=aspnetwf;Integrated Security=True"
providerName="System.Data.SqlClient"/>

    </connectionStrings>

  1. Press F5 to run the web hosting project

  1. Set the WFWCFWindowsService project to the startup project and press F5 to run the NT Service hosted project. It runs as a console application by default to aid in debugging
  2. Right click and start the WCFClient project to connect to the NT Service.

  1. Continue to customise the code for your host requirements.