简体   繁体   中英

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.

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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