Search code examples
c#wcf.net-4.0workflow-foundation-4workflow-services

Debug coded WorkflowServiceHost


Is it possible to debug a coded Windows Workflow .Net 4.0.1 self-hosted WorkflowServiceHost? I have

<system.web>
  <compilation debug="true" />
</system.web>

set in the app.config file. However, whenever I set a break point, the debugger stops at the point when the WorkflowServiceHost object is being constructed and not when an individual workflow instance reaches the break point.

By "coded" I mean the workflow is specified in C# instead of in the visual designer.


Solution

  • I have been in similar position with a variety of Flow chart and sequential workflows hosted in different containers. I found that using the Microsoft.Activities.UnitTesting framework made my life a lot easier when it came to testing workflows. The library is available as a nuGet package. Comple details here

    It makes it very easy to run workflows in "test hosts" which are special classes that provide the ability to run workflows as they would normally run in workflowinvoker, workflowservicehost etc. but offer a vast array of features that allow you to debug, trace your workflows.

    Getting started is easy, loads of samples already provided (including the samples to test workflow service hosts hosted workflows).

    I will highly recommend using this library, there is hardly a learning curve and it makes it very easy to test workflows.

    Hope this helps.

    One caveat though, make sure you have .NET framework 4 Platform Update 1 installed if you plan to use it. More details on this update here available here