简体   繁体   English

将 Windows 工作流程从 .Net 4.5 降级到 4.0

[英]Downgrading windows workflow from .Net 4.5 to 4.0

I develop workflows using .Net framework 4.5 (C#) and they are tested and working perfectly, unfortunately i have to downgrade .Net framework to 4.0, I know that xaml schema for WF has been changed in .Net 4.5我使用 .Net 框架 4.5 (C#) 开发工作流,它们经过测试并且运行良好,不幸的是我必须将 .Net 框架降级到 4.0,我知道 WF 的 xaml 架构已在 .Net 4.5 中更改

I search how to downgrade WF from .Net 4.5 to 4.0 but i cannot find anything that is helpful.我搜索了如何将 WF 从 .Net 4.5 降级到 4.0,但我找不到任何有用的东西。 I found this article but i cannot figure out what to do: WF projects that use new .NET 4.5 features fail to build when re-targeted to .NET Framework 4我找到了这篇文章,但我不知道该怎么做: 重新定位到 .NET Framework 4 时,使用新 .NET 4.5 功能的 WF 项目无法构建

Anyone know a well-known tested steps that i could follow to downgrade .Net framework to 4.0?任何人都知道一个众所周知的测试步骤,我可以按照这些步骤将 .Net 框架降级到 4.0? or should I redevelop workflows again using .Net framework 4.0?还是应该使用 .Net framework 4.0 重新开发工作流?

I did this a short while ago, and it is possible.我不久前这样做了,这是可能的。 Here's what I did:这是我所做的:

  1. Change the target .NET Framework version in the project properties to 4.0.将项目属性中的目标 .NET Framework 版本更改为 4.0。
  2. You'll need to manually edit your workflow's XAML file, by viewing it in an XML editor.您需要通过在 XML 编辑器中查看来手动编辑工作流的 XAML 文件。 Each expression parameter you have written in C# form will need to be converted to its VB.NET equivalent.您以 C# 形式编写的每个表达式参数都需要转换为其 VB.NET 等效项。 I found it easier to simply clear out the C# expression in the XAML, then open the designer and enter in the expression again using VB.NET syntax.我发现简单地清除 XAML 中的 C# 表达式更容易,然后打开设计器并使用 VB.NET 语法再次输入表达式。 This is the tedious part in large workflows.这是大型工作流中乏味的部分。
  3. You'll notice that in a v4.5 workflow format the list of namespaces will be in an element named TextExpression.NamespacesForImplementation .您会注意到,在 v4.5 工作流格式中,命名空间列表将位于名为TextExpression.NamespacesForImplementation的元素中。 Remove this element (and its child elements) from the XAML.从 XAML 中删除此元素(及其子元素)。
  4. Also, remove the element TextExpression.ReferencesForImplementation and its child elements.此外,删除元素TextExpression.ReferencesForImplementation及其子元素。
  5. In the root activity element, find the line that imports the clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities namespace.在根活动元素中,找到导入clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities命名空间的行。 Remove that XML namespace.删除那个 XML 命名空间。 For me, the namespace was prefixed with mca .对我来说,命名空间以mca为前缀。
  6. You'll need to hunt for any mca: prefixed elements, as they are no longer valid in a .NET 4.0-based workflow.您需要寻找任何mca:前缀元素,因为它们在基于 .NET 4.0 的工作流中不再有效。 Typically these will be any C# expressions that activities could be written in. Also, most if not all of these would likely be resolved already by the actions done in step 2 above.通常,这些将是可以写入活动的任何 C# 表达式。此外,即使不是全部,也可以通过上述步骤 2 中完成的操作来解决大部分问题。
  7. You'll need to re-add any namespaces you need using the designer's import tab.您需要使用设计器的导入选项卡重新添加您需要的任何命名空间。
  8. After all that, you should be able to build your downgraded workflow.毕竟,您应该能够构建降级的工作流程。

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

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