Question

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.

Was it helpful?

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

OTHER TIPS

Is your Workflow dll is located in Different Project ?

MSDN says

If a workflow host application and workflow DLL are located in different Visual Studio projects, for example, when you are using a workflow activity library, you must set the workflow DLL project as the Visual Studio solution startup project to debug the workflow using F5. You must also set the path to the host application in the workflow DLL project’s Start external program property.

To set a startup project in Solution Explorer, right-click the project name and select Set as StartUp Project. To set the path to the host in the Start external program property, double-click the workflow project’s Properties node in Solution Explorer and select the Debug tab. Under Start Action, select Start external program and enter the path to the .exe file that is hosting the workflow you want to debug.

If the host application is set as the startup project, only the Visual Studio debugger is invoked for debugging; the Visual Studio 2010 Debugger for Windows Workflow Foundation is not invoked. If the Visual Studio debugger is used, only C# or Visual Basic code breakpoints are hit; breakpoints set in the workflow designer are not hit. For example, a breakpoint that you set on a ParallelActivity activity in the designer is hit if the Visual Studio 2010 Debugger for Windows Workflow Foundation is used, but not when you use the Visual Studio debugger.

See if it helps you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top