简体   繁体   English

是什么导致WF4抱怨不正确的呼叫?

[英]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) GetWorkflowId(检索工作流ID的简单自定义步骤)
  2. InitializeCorrelation (vanilla) InitializeCorrelation(香草)
  3. Receive Xyz 接收Xyz

There are 9 receives in the workflow in all. 工作流中总共有9个接收。 When I run through them all in my unit test (using WorkflowServiceTestHost) it works just fine. 当我在单元测试中(使用WorkflowServiceTestHost)对它们全部进行处理时,它就可以正常工作。

However, when I try to call the first receive entrypoint (Xyz) from a client, I get the following error: 但是,当我尝试从客户端调用第一个接收入口点(Xyz)时,出现以下错误:

Operation 'Xyz|{ http://tempuri.org/ }IService' on service instance with identifier 'ffd6c56d-529f-4f42-ba81-f30c5ea9348d' cannot be performed at this time. 目前无法在标识符为'ffd6c56d-529f-4f42-ba81-f30c5ea9348d'的服务实例上执行操作'Xyz | { http://tempuri.org/ } IService'。 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. 我有一个SQL Server持久性数据库,并已对其进行工作流实例检查,但是InstancesTable始终为空。

I am beginning to wonder if I have hit a bug in WF4. 我开始怀疑我是否遇到了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. System.NotSupportedException:表达式活动类型'CSharpValue`1'需要进行编译才能运行。 Please ensure that the workflow has been compiled. 请确保工作流程已编译。

Which I found when I enabled WF tracing (see link ). 启用WF跟踪时找到的内容(请参阅链接 )。 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. 通过查看相关问题, 使用C#表达式Activity的 XAMLX工作流 在C#表达式使用引用类型时引发异常,我意识到,由于我已经覆盖了WorkflowServiceHostFactory ,因此现在必须显式编译C#表达式。 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. 其中WorkflowUtilities是我在其中放置从其他位置粘贴的代码以进行表达式编译的类。

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

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