title: How can I invoke this workflow?
body: <pre><code>static void Main(string[] args)
  {
        WorkflowDbContext db = new WorkflowDbContext();
  
        var workflowFromDb = db.Workflows.Find("1");
  
        string workFlowDefinition = workflowFromDb.WorkflowDefinition; 
  
        ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
        {
            CompileExpressions = true
        };
  }
  </code></pre>
  
  <p>When I try this:</p>
  
  <pre><code>DynamicActivity&lt;int&gt; wf = ActivityXamlServices.Load(new StringReader(workFlowDefinition), settings) as DynamicActivity&lt;int&gt;;
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>CacheMetadata for activity 'PeakTriggerActivities.SalesToService' threw 'System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:PeakTriggerActivities}GetTouchPoint'.
  </code></pre>
  
  <p>I have also tried this, but wf just becomes a null value in this case:</p>
  
  <pre><code>//Encoding this way since xml file shows utf-16
  MemoryStream mStream = new MemoryStream(Encoding.Unicode.GetBytes(workFlowDefinition));
  //Also tried LocalAssembly = System.Reflection.Assembly.GetExecutingAssembly() instead of LocalAssembly = typeof(GetTouchPoint).Assembly
  DynamicActivity&lt;int&gt; wf = ActivityXamlServices.Load(new XamlXmlReader(mStream, new XamlXmlReaderSettings { LocalAssembly = typeof(GetTouchPoint).Assembly }), settings) as DynamicActivity&lt;int&gt;;
  </code></pre>
  
  <p>This is what the workFlowDefinition string contains, and the class called GetTouchPoint is in the same project as this main method in program.cs:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
  &lt;Activity mc:Ignorable="sap sap2010 sads" x:Class="PeakTriggerActivities.SalesToService"     sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#"     sap2010:WorkflowViewState.IdRef="PeakTriggerActivities.SalesToService_1"
   xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
   xmlns:local="clr-namespace:PeakTriggerActivities"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
   xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
   xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
   xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
   xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
   xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
   xmlns:t="clr-namespace:TouchPointModels;assembly=TouchPointModels"
   xmlns:t1="clr-namespace:TouchPointServices;assembly=TouchPointService"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
    &lt;TextExpression.NamespacesForImplementation&gt;
      &lt;sco:Collection x:TypeArguments="x:String"&gt;
        &lt;x:String&gt;System&lt;/x:String&gt;
        &lt;x:String&gt;System.Collections.Generic&lt;/x:String&gt;
        &lt;x:String&gt;System.Data&lt;/x:String&gt;
        &lt;x:String&gt;System.Linq&lt;/x:String&gt;
        &lt;x:String&gt;System.Text&lt;/x:String&gt;
        &lt;x:String&gt;TouchPointModels&lt;/x:String&gt;
      &lt;/sco:Collection&gt;
    &lt;/TextExpression.NamespacesForImplementation&gt;
    &lt;TextExpression.ReferencesForImplementation&gt;
      &lt;sco:Collection x:TypeArguments="AssemblyReference"&gt;
        &lt;AssemblyReference&gt;Microsoft.CSharp&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;PresentationCore&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;PresentationFramework&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Activities&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Activities.Presentation&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Core&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Data&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Runtime.Serialization&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.ServiceModel&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.ServiceModel.Activities&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.ServiceModel.Channels&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Xaml&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Xml&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;System.Xml.Linq&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;WindowsBase&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;TouchPointModels&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;TouchPointService&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;mscorlib&lt;/AssemblyReference&gt;
        &lt;AssemblyReference&gt;PeakTriggerActivities&lt;/AssemblyReference&gt;
      &lt;/sco:Collection&gt;
    &lt;/TextExpression.ReferencesForImplementation&gt;
    &lt;Sequence sap2010:WorkflowViewState.IdRef="Sequence_1"&gt;
      &lt;Sequence.Variables&gt;
        &lt;Variable x:TypeArguments="x:String" Name="varTouchPointCode" /&gt;
        &lt;Variable x:TypeArguments="t:TouchPoint" Name="varTouchPoint" /&gt;
        &lt;Variable x:TypeArguments="x:Int32" Name="varProgramNumber" /&gt;
      &lt;/Sequence.Variables&gt;
      &lt;local:GetTouchPoint Text="{x:Null}" sap2010:WorkflowViewState.IdRef="GetTouchPoint_1"     InProgramNumber="1" InTouchPointCode="SATM"&gt;
        &lt;local:GetTouchPoint.OutProgramNumber&gt;
          &lt;OutArgument x:TypeArguments="x:Int32"&gt;
            &lt;mca:CSharpReference x:TypeArguments="x:Int32"&gt;varProgramNumber&lt;/mca:CSharpReference&gt;
          &lt;/OutArgument&gt;
        &lt;/local:GetTouchPoint.OutProgramNumber&gt;
        &lt;local:GetTouchPoint.OutTouchPoint&gt;
          &lt;OutArgument x:TypeArguments="t:TouchPoint"&gt;
            &lt;mca:CSharpReference x:TypeArguments="t:TouchPoint"&gt;varTouchPoint&lt;/mca:CSharpReference&gt;
          &lt;/OutArgument&gt;
        &lt;/local:GetTouchPoint.OutTouchPoint&gt;
        &lt;local:GetTouchPoint.OutTouchPointCode&gt;
          &lt;OutArgument x:TypeArguments="x:String"&gt;
            &lt;mca:CSharpReference x:TypeArguments="x:String"&gt;varTouchPointCode&lt;/mca:CSharpReference&gt;
          &lt;/OutArgument&gt;
        &lt;/local:GetTouchPoint.OutTouchPointCode&gt;
      &lt;/local:GetTouchPoint&gt;
      &lt;If sap2010:WorkflowViewState.IdRef="If_1"&gt;
        &lt;If.Condition&gt;
          &lt;InArgument x:TypeArguments="x:Boolean"&gt;
            &lt;mca:CSharpValue x:TypeArguments="x:Boolean"&gt;varTouchPoint == null&lt;/mca:CSharpValue&gt;
          &lt;/InArgument&gt;
        &lt;/If.Condition&gt;
        &lt;If.Then&gt;
          &lt;WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_1"&gt;
            &lt;InArgument x:TypeArguments="x:String"&gt;
              &lt;mca:CSharpValue x:TypeArguments="x:String"&gt;"Cannot find Touchpoint Code :" +     varTouchPointCode&lt;/mca:CSharpValue&gt;
            &lt;/InArgument&gt;
          &lt;/WriteLine&gt;
        &lt;/If.Then&gt;
        &lt;If.Else&gt;
          &lt;Sequence sap2010:WorkflowViewState.IdRef="Sequence_2"&gt;
            &lt;WriteLine sap2010:WorkflowViewState.IdRef="WriteLine_3"&gt;
              &lt;InArgument x:TypeArguments="x:String"&gt;
                &lt;mca:CSharpValue x:TypeArguments="x:String"&gt;"Processing Touchpoint: " +  varTouchPoint.Code + " - " + varTouchPoint.Name&lt;/mca:CSharpValue&gt;
              &lt;/InArgument&gt;
            &lt;/WriteLine&gt;
            &lt;t1:ProcessTouchPoint InTouchPoint="{x:Null}" Success="{x:Null}" Text="{x:Null}" sap2010:WorkflowViewState.IdRef="ProcessTouchPoint_1"&gt;
              &lt;t1:ProcessTouchPoint.InProgramNumber&gt;
                &lt;InArgument x:TypeArguments="x:Int32"&gt;
                  &lt;mca:CSharpValue x:TypeArguments="x:Int32"&gt;varProgramNumber&lt;/mca:CSharpValue&gt;
                &lt;/InArgument&gt;
              &lt;/t1:ProcessTouchPoint.InProgramNumber&gt;
              &lt;t1:ProcessTouchPoint.InTouchPointCode&gt;
                &lt;InArgument x:TypeArguments="x:String"&gt;
                  &lt;mca:CSharpValue x:TypeArguments="x:String"&gt;varTouchPointCode&lt;/mca:CSharpValue&gt;
                &lt;/InArgument&gt;
             &lt;/t1:ProcessTouchPoint.InTouchPointCode&gt;
            &lt;/t1:ProcessTouchPoint&gt;
          &lt;/Sequence&gt;
        &lt;/If.Else&gt;
      &lt;/If&gt;
      &lt;sads:DebugSymbol.Symbol&gt;d0tDOlxwcm9qZWN0c1xQZWFrVHJpZ2dlckFjdGl2aXRpZXNcUGVha1RyaWdnZXJBY3Rpdml0aWVzXFNhbGVzVG9TZXJ2aWNlLnhhbWwRMANrDgIBATYFRhsCARtHBWkKAgECNoEBNocBAgEpOQs5YAIBJUMLQ2ICASE+Cz5iAgEdNmw2bwIBHEoLSl8CAQNOCVIVAgEWVQlnFAIBB1ANUH4CARdWC1oXAgERWwtmIgIBCFgPWJgBAgESYxFjYAIBDV4RXl4CAQk=    &lt;/sads:DebugSymbol.Symbol&gt;
    &lt;/Sequence&gt;
    &lt;sap2010:WorkflowViewState.ViewStateManager&gt;
      &lt;sap2010:ViewStateManager&gt;
        &lt;sap2010:ViewStateData Id="GetTouchPoint_1" sap:VirtualizedContainerService.HintSize="469,22" /&gt;
        &lt;sap2010:ViewStateData Id="WriteLine_1" sap:VirtualizedContainerService.HintSize="211,62" /&gt;
        &lt;sap2010:ViewStateData Id="WriteLine_3" sap:VirtualizedContainerService.HintSize="211,62" /&gt;
        &lt;sap2010:ViewStateData Id="ProcessTouchPoint_1"   sap:VirtualizedContainerService.HintSize="211,22" /&gt;
        &lt;sap2010:ViewStateData Id="Sequence_2" sap:VirtualizedContainerService.HintSize="233,248"&gt;
          &lt;sap:WorkflowViewStateService.ViewState&gt;
            &lt;scg:Dictionary x:TypeArguments="x:String, x:Object"&gt;
              &lt;x:Boolean x:Key="IsExpanded"&gt;True&lt;/x:Boolean&gt;
            &lt;/scg:Dictionary&gt;
          &lt;/sap:WorkflowViewStateService.ViewState&gt;
        &lt;/sap2010:ViewStateData&gt;
        &lt;sap2010:ViewStateData Id="If_1" sap:VirtualizedContainerService.HintSize="469,398" /&gt;
        &lt;sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="491,584"&gt;
          &lt;sap:WorkflowViewStateService.ViewState&gt;
            &lt;scg:Dictionary x:TypeArguments="x:String, x:Object"&gt;
              &lt;x:Boolean x:Key="IsExpanded"&gt;True&lt;/x:Boolean&gt;
            &lt;/scg:Dictionary&gt;&lt;/sap:WorkflowViewStateService.ViewState&gt;
  &lt;/sap2010:ViewStateData&gt;
  &lt;sap2010:ViewStateData Id="PeakTriggerActivities.SalesToService_1"   sap:VirtualizedContainerService.HintSize="531,664" /&gt;
  &lt;/sap2010:ViewStateManager&gt;
  &lt;/sap2010:WorkflowViewState.ViewStateManager&gt;
  &lt;/Activity&gt;
  </code></pre>