locked
Load workflows and sub-workflow xaml from disk RRS feed

  • Question

  • Hi,

    We created some workflows xamls that contains other sub-workflows xamls, and we deploy them (both workflows and sub-workflows) in a specific folder.  Our user can modify those xamls (both workflows and sub-workflows) without recompiling if it is not necessary.

    Currently we load the workflows from the disk using ActivityXamlServices, so it covers the case when we modify the workflows, but it doesn't when the sub-workflow is modified, and we have to recompile the project.

    This is a simple scenario:

    Workflow.xaml that contains Activity1:

    <Activity mc:Ignorable="sap" x:Class="Workflows.Workflow" sap:VirtualizedContainerService.HintSize="240,240" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:a="clr-namespace:ActivityLibrary;assembly=ActivityLibrary" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    Activity1.xaml:

    <Activity x:Class="ActivityLibrary.Activity1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    If we modify Activity1.xaml we must recompile now... <-- Avoid this!

    The solution that I'm thinking is compile on runtime using XamlBuildTask.. Do you think it is the right solution to follow? Other options?

    Thanks in advance!

    Thursday, April 4, 2013 10:39 AM

All replies

  • I have been investigating a bit the topic... and first I tried to follow the XamlBuildTask workarround of the next link: http://blogs.msdn.com/b/tilovell/archive/2011/02/19/secrets-of-the-xaml-build-task.aspx

    But, it seems a bit complicate for what I want to do here.

    So, I think the only way to go is compile at runtime my xamls using msbuild support.

    Any comment or idea?

    Friday, April 5, 2013 2:10 PM
  • You can generate a dynamic assembly in the memory:

    1) Implement a template activity, which can wrap around the dynamic activity, loaded from xaml.

    2) Generate an assembly with fixed name, with dynamic types filled with certain xamls.

    3) Load generated assembly in the app

    But it seems to be rather complex approach :)

    And how do you plan to manage long-running workflows, if your users modify some activities which are still working and persisted? I think changed activities in this case can not be correctly restored from the store.

     Thanks, Serge

    Friday, May 17, 2013 9:28 AM