我正在学习Windows Workflow Foundation 4,并尝试创建以下程序:
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Workflow1包含一个单独的动作,称为Activity1。Activity1.xaml由单个Writeline组成。
当我将工作流作为已编译的Activity加载时(通过使用“ Activity wf = new Workflow1()”),程序将完美加载。当我尝试为活动加载XAML时(如上面的代码),出现异常:无法创建未知类型'{clr-namespace:} Activity1'。
我想我也必须以某种方式加载其他xaml文件,尽管我对此非常困惑。
供您参考。...Workflow1.xaml:
<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:">
<Sequence …Run Code Online (Sandbox Code Playgroud)