none
Referencing a dynamic activity from another dynamic activity RRS feed

  • Question

  • I have multiple activities, stored as XAML in a database, that are loaded dynamically at runtime using the following method:

    Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xamlString));
    var settings = new ActivityXamlServicesSettings() { CompileExpressions = true };
    Activity wf = ActivityXamlServices.Load(stream, settings);
    IDictionary<string, object> results = WorkflowInvoker.Invoke(wf); 

    This works fine for the most part, but let's say I'm working with two activities:

    <Activity x:Class="ExampleWorkflow.NestedActivity"
     xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
     xmlns:local="clr-namespace:ExampleWorkflow"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <WriteLine Text="Got here!" />
    </Activity>
    <Activity x:Class="ExampleWorkflow.MainActivity"
     xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
     xmlns:local="clr-namespace:ExampleWorkflow"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <local:NestedActivity />
    </Activity>

    If I try to invoke MainActivity, I get the following error: "Cannot create unknown type '{clr-namespace:ExampleWorkflow}NestedActivity", which makes sense since I never loaded NestedActivity.

    Is there a way to also load the NestedActivity dynamically, so that it's available when MainActivity runs?




    • Edited by jon.pocock Wednesday, July 10, 2019 8:20 PM
    Wednesday, July 10, 2019 8:14 PM