简体   繁体   English

WF4.5不编译并行的C#工作流程

[英]WF4.5 not compiling side-by-side c# workflows

I have an IIS hosted xamlx workflow with c# expressions that I'm trying to run in side-by-side versioning. 我有一个IIS托管的xamlx工作流,它带有要在并行版本控制中运行的c#表达式。

I did exactly like this article: Side by side versioning of workflow services 我确实喜欢这篇文章: 工作流服务的并行版本控制

New instances of the workflow works as expected, but when I call an instance of a prior version of the workflow, it raises an error telling me that it's not compiled. 工作流的新实例可以按预期工作,但是当我调用工作流的早期版本的实例时,它将引发一个错误,告诉我它尚未编译。

Error: 错误:

Unable to locate the ICompiledExpressionRoot for compiled location 'auxData'. 无法找到编译位置“ auxData”的ICompiledExpressionRoot。 Make sure that the definition for the activity containing this expression has been compiled. 确保包含该表达式的活动的定义已被编译。

BTW, I have a custom factory that compiles the workflow. 顺便说一句,我有一个自定义工厂来编译工作流程。

<serviceActivations>        
    <add service="Service1.xamlx" relativeAddress="~/Service1.xamlx" factory="MyServiceHostFactory" />
</serviceActivations>

After analyzing the source code from .Net, I realized that the method CreateWorkflowServiceHost that I override in my custom workflow factory, adds all supported versions in it's return object. 在分析了.Net的源代码之后,我意识到我在自定义工作流工厂中重写的CreateWorkflowServiceHost方法在其返回对象中添加了所有受支持的版本。

All I had to do is iterate this collection and compile them all. 我要做的就是迭代这个集合并编译它们。

Final source code: 最终源代码:

    protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)
    {
        var host = base.CreateWorkflowServiceHost(service, baseAddresses);

        // add your customizations here…
        CompileExpressions(service.Body);
        foreach (var supportedVersion in host.SupportedVersions)
        {
            CompileExpressions(supportedVersion.Body);
        }

        return host;
    }        

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM