Workflow Foundation 4.5“表达式活动类型‘CSharpValue‘1’需要编译才能运行." [英] Workflow Foundation 4.5 "Expression Activity type 'CSharpValue`1' requires compilation in order to run."

查看:32
本文介绍了Workflow Foundation 4.5“表达式活动类型‘CSharpValue‘1’需要编译才能运行."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 WF45 的入门教程,并且有遇到其他人似乎遇到过的问题,但与我遇到的问题不同.我希望其他人为我提供解决方案.

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

"表达式活动类型'CSharpValue`1'需要在命令运行.请确保工作流已编译."

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

我已尝试从 Windows Workflow Foundation (WF45) - 入门教程 以防我错过了一步但错误仍然存​​在.

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.

在线阅读似乎需要编译带有嵌入式 C# 表达式的工作流,但据我了解,在使用 VS2012 和工作流设计器时,默认情况下会发生这种情况?我试图实现在 here 中找到的 CompileExpressions 方法,但这没有帮助.我确实读到在预发布版本中存在一个问题,其中 C# 表达式导致了这个问题,但 VB 项目仍然有效.对此进行测试,我发现我正在遭受这种确切的情况.VB 教程运行良好,但 C# 版本因此异常而失败.

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? I have tried to implement the CompileExpressions method found here but that did not help. I did read that there was a problem during the pre-release version where C# expressions caused this problem, and yet VB projects worked. Testing this, I see that I am suffering this exact case. The VB tutorial runs fine, but the C# version fails with this exception.

另外,我敢说:这不是我同事机器上的问题,所以我认为是我机器上的配置问题...

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

更新&闪避修复:

所以,我已经设法解决了这个问题,尽管我对解决方案并不满意,并且很想听听是否有人对这种情况有正当的理由.

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.

我的解决方法是将 Frameworkv4.0.30319 文件夹中的 Microsoft.Common.targets 文件替换为我同事的同一文件版本.这已经解决了这个问题.它还有什么坏处还有待观察...

My fix was to replace my Microsoft.Common.targets file in the Frameworkv4.0.30319 folder with my colleague's version of the same file. 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);

这是工作代码:

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

这篇关于Workflow Foundation 4.5“表达式活动类型‘CSharpValue‘1’需要编译才能运行."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆