简体   繁体   English

Workflow Foundation 4.5“表达式活动类型'CSharpValue`1'需要编译才能运行。”

[英]Workflow Foundation 4.5 “Expression Activity type 'CSharpValue`1' requires compilation in order to run.”

I am working through the Getting Started Tutorial for WF45 and have run into a problem that looks to have been experience by other people, but not in the same way that I am experiencing it. 我正在研究WF45的入门教程并遇到了一个看起来像其他人一样经历过的问题,但问题与我遇到的问题不一样。 I am hoping that someone else has a solution for me. 我希望其他人有我的解决方案。

When I work through the Tutorial, all is good till I have to run it from the workflow host. 当我完成教程时,一切都很好,直到我必须从工作流主机运行它。 At that point the instantiation of the workflow fail and returns the following message. 此时,工作流的实例化失败并返回以下消息。

"Expression Activity type 'CSharpValue`1' requires compilation in order to run. Please ensure that the workflow has been compiled." “表达式活动类型'CSharpValue`1'需要编译才能运行。请确保已编译工作流。”

I have tried downloading the source from Windows Workflow Foundation (WF45) - Getting Started Tutorial in case I had missed a step but the error still persists. 我尝试从Windows Workflow Foundation(WF45) - 入门教程下载源代码,以防我错过了一个步骤,但错误仍然存​​在。

Reading online it seems that workflows with embedded C# expressions need to be complied, but as I understand it this happens by default when using VS2012 and the workflow designer? 在线阅读似乎需要编译带有嵌入式C#表达式的工作流,但据我所知,这在使用VS2012和工作流设计器时会默认发生? I have tried to implement the CompileExpressions method found here but that did not help. 我试图实现这里找到的CompileExpressions方法但这没有帮助。 I did read that there was a problem during the pre-release version where C# expressions caused this problem, and yet VB projects worked. 我确实读过在预发布版本中存在一个问题,其中C#表达式导致了这个问题,但VB项目仍然有效。 Testing this, I see that I am suffering this exact case. 测试这个,我看到我正在遭受这种确切的情况。 The VB tutorial runs fine, but the C# version fails with this exception. VB教程运行正常,但C#版本因此异常而失败。

Furthermore and dare I mention it: This is not a problem on my colleague's machine, so I think it is a configuration problem on my machine... 此外,我敢提一下:这对我同事的机器来说不是问题,所以我认为这是我机器上的配置问题......

Update & dodge fix: 更新和躲闪修复:

So, I have managed to fix the problem, although I am not happy with the solution and would love to hear if anyone has a decent reason for this happening. 所以,我已经设法解决了这个问题,虽然我对解决方案不满意,并且很想知道是否有人有这样的理由发生这种情况。

My fix was to replace my Microsoft.Common.targets file in the \\Framework\\v4.0.30319 folder with my colleague's version of the same file. 我的修复是用我同事的同一文件版本替换\\ Framework \\ v4.0.30319文件夹中的Microsoft.Common.targets文件。 This has solved the problem. 这解决了这个问题。 What else it has broken remains to be seen... 它还有什么破坏还有待观察......

The original Problem thread is pretty old, but may be your find that helpfull either. 最初的问题线程已经很老了,但也许你的发现也很有帮助。

I had the same Problem with my dynamic activities and found that the documentation is wrong: 我的动态活动遇到了同样的问题,发现文档错误:

This is the code which produces the error above: 这是产生上述错误的代码:

string path = @"myActivity.xaml"; string path = @“myActivity.xaml”;

            Activity activity = ActivityXamlServices.Load(path);



            IDictionary<string, object> dictionary = new Dictionary<string, object>
            {
                { "Arg", 1},
            };

            IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);

and this is the working code: 这是工作代码:

string path = @"myActivity.xaml"; string path = @“myActivity.xaml”;

            ActivityXamlServicesSettings settings = new ActivityXamlServicesSettings
            {
                CompileExpressions = true
            };


            Activity activity = ActivityXamlServices.Load(path, settings);

            IDictionary<string, object> dictionary = new Dictionary<string, object>
            {
                { "ArgNumberToEcho", 2},
            };

            IDictionary<string, object> output = WorkflowInvoker.Invoke(activity, dictionary);

This might help someone - what worked for me was I had line breaks in the Expression window for one my of Assigns. 这可能对某些人有所帮助 - 对我有用的是我在“表达式”窗口中为一个我的Assigns设置了换行符。 Removed the line breaks and it started working. 删除换行符并开始工作。

Another cause of this error is when an expression has too many \\r\\n in the value. 此错误的另一个原因是表达式中的\\ r \\ n中有太多\\ r \\ n。

So if you had an Assign activity with something like this for the "Value" section 因此,如果您为“值”部分设置了具有类似内容的Assign活动

new myobject(){
     param1=val1,
     param2=val2,   
     param3=val3,
     param4=val4,
     param5=val5,    
     param6=val6,
}

Change it to this: 把它改成这个:

new myobject(){param1=val1,param2=val2,param3=val3,param4=val4,param5=val5,param6=val6,}

Now hold both thumbs and hope it fixes the error. 现在握住两个拇指,并希望它修复错误。

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

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