Rehosting the WF designer in an application outside of Visual Studio is nothing new and since WF4, nothing particularly difficult. In fact the WF product team has gone out of its way to make rehosting the designer as easy an experience as possible and they’ve done a great job. The WCF and WF Samples for .NET Framework 4 provides code samples for rehosting the designer with its corresponding toolbox and properties grid. The samples also cover handling validation errors, executing workflows and providing some level of debugging through workflow tracking – most of what you need to write your own rehosted designer.
Here’s a rundown of its features and where appropriate I've provided references to sample code should you want to understand more about the implementation detail.
1: <!-- for output, add new sources here where name must match workflow name without file extension, suffixed with "Output" -->
2: <source name="TestLoopWithDelayOutput"
3: switchType="System.Diagnostics.SourceSwitch"
4: switchName="verboseSwitch">
5: <listeners>
6: <add name="testLoopWithDelayOutputListener"
7: type="System.Diagnostics.TextWriterTraceListener"
8: initializeData="TestLoopWithDelayOutput.log">
9: </add>
10: <remove name="Default"/>
11: </listeners>
12: </source>
1: <!-- The AllOutput source captures output for all workflows -->
2: <source name="AllOutput"
6: <add name="allOutputListener"
8: initializeData="AllOutput.log">
Hopefully you’ll find Workflow Studio a useful application for designing and debugging workflows in environments where Visual Studio is not a viable option. You can even use it for simple workflow hosting. It’ll save you writing a lot of boiler plate code and can serve as a starting point for your own implementation should you require something more specialized. I’d be interested to hear if you find Workflow Studio useful and welcome any feedback for possible enhancements. Also, please let me know of any bugs you may find.
Workflow Studio has been updated for .NET 4.5 to take advantage of some of the new designer improvements. If you are using .NET 4.5 and Visual Studio 2012 then it is recommended you use the version described in this post.
Written by Christopher Owczarek