【问题标题】:Using sub workflow inside main workflow在主工作流程中使用子工作流程
【发布时间】:2017-05-24 07:55:18
【问题描述】:

当我在内部使用另一个工作流时,以动态方式加载工作流 XAML 时遇到问题。

我的主要工作流程 - MainWorkflow.xaml。在另一个工作流程中 - SubWorkflow.xaml 在运行时当我加载 Main.xaml 时出现以下错误:

{"CacheMetadata for activity 'FlowManager.Flows.MainWorkflow' through 'System.Xaml.XamlObjectWriterException: Cannot create unknown type '{clr-namespace:FlowManager.Flows}SubWorkflow'

加载工作流的代码:

public object Load(Dictionary<string, object> inputs)
{
    object returnValue = null;

    ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
    {
        //since the workflow contains expression, the following flag must be set to true
        CompileExpressions = true
    };


    WorkflowApplication wfApp =
        new WorkflowApplication(
            ActivityXamlServices.Load(Path, settings), inputs)
        {
            Completed = delegate (WorkflowApplicationCompletedEventArgs e)
            {
                returnValue = e.Outputs["returnValue"];
                syncEvent.Set();
            },
            Idle = delegate (WorkflowApplicationIdleEventArgs e) { idleEvent.Set(); }                    
    };

    wfApp.Run();
    syncEvent.WaitOne();
    return returnValue;
}

通过创建 Main 实例而不是通过加载 XAML 来更改工作流的加载,效果很好

        WorkflowApplication wfApp =
            new WorkflowApplication(new MainWorkflow(), inputs)

任何想法我如何解决这个问题?

【问题讨论】:

    标签: c# xaml workflow-foundation-4 workflow-foundation


    【解决方案1】:

    找到答案,需要用 XamlXmlReaderSettings 对象添加程序集引用

        var xamlReaderSettings = new XamlXmlReaderSettings()
        {
            LocalAssembly = typeof(GetVmIp).Assembly
        };
        var reader = new XamlXmlReader(Path, xamlReaderSettings);
    
    
        WorkflowApplication wfApp =
            new WorkflowApplication(
                ActivityXamlServices.Load(reader, settings), inputs)
    

    它有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多