WF4.5 not compiling side-by-side c# workflows

感情迁移 提交于 2019-12-19 10:15:46

问题


I have an IIS hosted xamlx workflow with c# expressions that I'm trying to run in side-by-side versioning.

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'. 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>

回答1:


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.

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;
    }        


来源:https://stackoverflow.com/questions/15412914/wf4-5-not-compiling-side-by-side-c-sharp-workflows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!