Thursday, December 17, 2009

Seeing as this has changed completely from WF 3.5 I thought I’d post a quick blog entry to describe how to run a workflow declared in a XAML file.

You may have heard that the WF 4.0 default authoring model is now XAML. However, the Visual Studio 2010 workflow projects store the XAML as a resource in the binary rather than as a text file. So if you want to deploy your workflows as XAML text files how do you run them? In .NET 3.5 you could pass the workflow runtime an XmlReader pointing at the XAML file but in WF 4.0 there is no WorkflowRuntime class. It turns out you need to load the XAML slightly indirectly by creating a special activity called a DynamicActivity

DynamicActivity has an Implementation member that points to a Func<Activity> delegate – in other words you wire up a method that returns an activity (the workflow). Here’s an example:

static void Main(string[] args)
{
  DynamicActivity dyn = new DynamicActivity();
  
  // this line wires up the workflow creator method
  dyn.Implementation = CreateWorkflow;
 
  WorkflowInvoker.Invoke(dyn);
}
 
static Activity CreateWorkflow()
{
  // we use the new XamlServices utility class to deserialize the XAML
  Activity act = (Activity)XamlServices.Load(@"..\..\workflow1.xaml");
 
  return act;
}
 |  | 
Thursday, December 17, 2009 3:27:07 PM (GMT Standard Time, UTC+00:00)  #    Comments [3]TrackbackTracked by:
http://topsy.com/tb/www.dotnetconsult.co.uk/weblog2/PermaLink,guid,3c481d20-caf5... [Pingback]
Sunday, December 20, 2009 6:14:56 PM (GMT Standard Time, UTC+00:00)
Sorry to post here, but there is no email contact. I believe a very long time ago you wrote something that shared memory for IPC between two .net apps. Unfortunately the source code is nowhere to be found. Would it be possible for you to repost this? Also, is this still a suggested method for apps that require data to be shared at high speed? I understand that IPC is now available, but is there more overhead in using this approach?
Tuesday, December 22, 2009 4:31:34 PM (GMT Standard Time, UTC+00:00)
Hi David

I'd look at using WCF and the NetNamedPipeBinding. This uses Shared Memory based named pipes under the covers
Richard
Sunday, February 28, 2010 7:59:57 AM (GMT Standard Time, UTC+00:00)
Shared Memory based named pipes ? are you sure?
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):