Search code examples
c#workflow-foundation-4workflow-foundation

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

I search how to downgrade WF from .Net 4.5 to 4.0 but i cannot find anything that is helpful. 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

Anyone know a well-known tested steps that i could follow to downgrade .Net framework to 4.0? or should I redevelop workflows again using .Net framework 4.0?


Solution

  • 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.
    2. You'll need to manually edit your workflow's XAML file, by viewing it in an XML editor. Each expression parameter you have written in C# form will need to be converted to its VB.NET equivalent. 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. 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. Remove this element (and its child elements) from the XAML.
    4. Also, remove the element TextExpression.ReferencesForImplementation and its child elements.
    5. In the root activity element, find the line that imports the clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities namespace. Remove that XML namespace. For me, the namespace was prefixed with 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. 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.
    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.