title: References when loading XAML Workflows
body: <p>I'm learning about Windows Workflow Foundation 4, and tried to create the following program:</p>
  
  <pre><code>using System;
  using System.Activities.XamlIntegration;
  using System.Linq;
  using System.Activities;
  using System.Activities.Statements;
  using System.Reflection;
  using System.Xaml;
  
  namespace BranchedActivities
  {
  
      class Program
      {
          static void Main(string[] args)
          {
              Activity wf = ActivityXamlServices.Load(@"C:\...\Workflow1.xaml");
              WorkflowInvoker.Invoke(wf);
  
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>Workflow1 comprises of a single action, calling Activity1. Activity1.xaml comprises of a single Writeline.</p>
  
  <p>When I load the workflow as a compiled Activity  (by using "Activity wf = new Workflow1()"), the program loads perfectly.
  When I try to load the XAML for the activity (like the code above), the get the exception: Cannot create unknown type '{clr-namespace:}Activity1'.</p>
  
  <p>I guess I have to somehow load the other xaml file as well, though I'm pretty stumped on how.</p>
  
  <p>For your reference.... Workflow1.xaml:</p>
  
  <pre><code>&lt;Activity mc:Ignorable="sap" x:Class="Workflow1" sap:VirtualizedContainerService.HintSize="262,240" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 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"
            xmlns:local="clr-namespace:"&gt;
    &lt;Sequence sad:XamlDebuggerXmlReader.FileName="C:\...\Workflow1.xaml" sap:VirtualizedContainerService.HintSize="222,200"&gt;
      &lt;sap:WorkflowViewStateService.ViewState&gt;
        &lt;scg3:Dictionary x:TypeArguments="x:String, x:Object"&gt;
          &lt;x:Boolean x:Key="IsExpanded"&gt;True&lt;/x:Boolean&gt;
        &lt;/scg3:Dictionary&gt;
      &lt;/sap:WorkflowViewStateService.ViewState&gt;
      &lt;local:Activity1 sap:VirtualizedContainerService.HintSize="200,22" /&gt;
    &lt;/Sequence&gt;
  &lt;/Activity&gt;
  </code></pre>
  
  <p>Activity1.xaml</p>
  
  <pre><code>&lt;Activity mc:Ignorable="sap" x:Class="Activity1" sap:VirtualizedContainerService.HintSize="273,240" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 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"&gt;
    &lt;Sequence sad:XamlDebuggerXmlReader.FileName="C:\...\Activity1.xaml" sap:VirtualizedContainerService.HintSize="233,200"&gt;
      &lt;sap:WorkflowViewStateService.ViewState&gt;
        &lt;scg3:Dictionary x:TypeArguments="x:String, x:Object"&gt;
          &lt;x:Boolean x:Key="IsExpanded"&gt;True&lt;/x:Boolean&gt;
        &lt;/scg3:Dictionary&gt;
      &lt;/sap:WorkflowViewStateService.ViewState&gt;
      &lt;WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="Hello World" /&gt;
    &lt;/Sequence&gt;
  &lt;/Activity&gt;
  </code></pre>