Windows Workflow 4: Dynamically Load Workflows

I’m starting a new project where I plan to use Windows Workflow Foundation to load custom jobs from external XML files like plug-ins. In order for this to work, I’ll have a sub-directory that my application watches. If files are found, they will be loaded and executed.

The reason I want to do this is because Windows Workflow Foundation 4 makes it easy to keep the workflows as human-readable XML files that can be edited by technical-but-not-developer users. This allows for easy, efficient customization of workflows. The processes we have now require developer interaction for any customization or modification since everything is compiled into DLLs making our development team an unnecessary bottleneck for warranty and enhancement.

Over the next days and weeks, I’ll be publishing a number of posts that demonstrate small nuggets of WF4 functionality. I’ve been impressed with what I’ve been able to accomplish in just a few days of fooling around, so this I’m very excited about this endeavor!

I’m keeping it short and simple with this post: loading and running an XML (XAML) workflow from a file at runtime. This very powerful functionality can be accomplished in a single line of code:

WorkflowInvoker.Invoke(ActivityXamlServices.Load("HelloWorld.xml"));

One of my main goals is encapsulating all of my functionality in human-readable XML, so I also wanted to provide the contents of my HelloWorld.xml file. This workflow is unimpressive and simply writes “Hello, world!” to the console, but here it is, nonetheless:

<Activity xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <WriteLine Text="Hello, world!" />
</Activity>
Advertisements

3 thoughts on “Windows Workflow 4: Dynamically Load Workflows”

    1. Certainly! I’ve been working on a workflow designer that allows me to create, modify, and run workflows outside of Visual Studio. (e.g., on a customer’s server) You can read more about the editor here: https://adamprescott.net/2012/08/06/windows-workflow-4-designer-wpf-application/

      The project is likely to go in a slightly different direction shortly as I try to add support for workflows into our existing, web-based framework.

      Did you have a more specific question about the project?

  1. Get thee ultimate low ԁown oon tgis fantastic store instantly іn oursuper overview to fab
    lebron james II. Bad odor оf your running shoes iѕ a direct consequence
    of fungus and bacteria living inn уοur shoes օf the
    sweat аnd skin particles yߋur feet left there.
    Τhey’гe typically nice collared shirts, ѕometimes with nice patterns or colorful
    designs, ѕometimes not.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s