简体   繁体   中英

What can cause WF4 to complain about out-of-sequence calls improperly?

I have a (pretty) simple workflow. The first three actions on the workflow are:

  1. GetWorkflowId (a simple custom step to retrieve the workflow ID)
  2. InitializeCorrelation (vanilla)
  3. Receive Xyz

There are 9 receives in the workflow in all. When I run through them all in my unit test (using WorkflowServiceTestHost) it works just fine.

However, when I try to call the first receive entrypoint (Xyz) from a client, I get the following error:

Operation 'Xyz|{ http://tempuri.org/ }IService' on service instance with identifier 'ffd6c56d-529f-4f42-ba81-f30c5ea9348d' cannot be performed at this time. Please ensure that the operations are performed in the correct order and that the binding in use provides ordered delivery guarantees.

I have tried all sorts of things to get more information on this but come up empty. I have a SQL Server persistence database and have checked it for the workflow instance but the InstancesTable there is always empty.

I am beginning to wonder if I have hit a bug in WF4.

The error displayed was bogus and misleading. The real error was

System.NotSupportedException: Expression Activity type 'CSharpValue`1' requires compilation in order to run. Please ensure that the workflow has been compiled.

Which I found when I enabled WF tracing (see link ). Looking at the related questions XAMLX Workflow with c# expressions and Activity throws exception when C# expression uses reference types I realized that since I had overridden WorkflowServiceHostFactory that I now had to explicitly compile the C# expressions. Doing so in the override fixed the problem.

The results look something like this:

 public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
 {
     var result = new WorkflowServiceHostFactory().CreateServiceHost(constructorString, baseAddresses) as WorkflowServiceHost;
     WorkflowUtilities.CompileExpressions(result.Activity);
     return result;
 }

Where WorkflowUtilities is the class in which I put the pasted-from-elsewhere code for doing the expression compilations.

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