Invalid type(s) error while publishing Activity to WorkflowManager

1.4k Views Asked by At

I've installed Worfklow Manger 1.0. I can use WorkflowManagerClient to browse scopes. But when I try to publish activity I get this error:

System.InvalidOperationException: Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors: Invalid type(s) 'System.Activities.Expressions.AssemblyReference'.

Activity is an empty activity created from template in VS. There is no custom types used in it. I've found this post and I quess I could create AllowedTypes.xml file but it feels wierd to add types that are used in base empty activity - basically system types (System.Activities.Expressions.AssemblyReference).

Do I need to create allowdtypes file and put System.Activities.Expressions.AssemblyReference as one type ? Did anyone have to do that ?

Edit:

Other types that caus the same error are:

Microsoft.CSharp.Activities.CSharpReference`1
Microsoft.CSharp.Activities.CSharpValue`1
2

There are 2 best solutions below

0
On BEST ANSWER

So it turns out that I should've used ExpressionTranslator to translade all activities before publish. The translation is a step in process of publishing of the Workflow in Workflow Manager. it basically translates all expressions in Workflow Activities in a form required by XAML, before the workflow is published (installed) to the host.

I've used Workflow Manager tutorial Translate method:

public static XElement Translate(string xamlFile)
    {
        string translatedWorkflowString = null;

        using (XamlReader xamlReader = new XamlXmlReader(xamlFile))
        {
            TranslationResults result = ExpressionTranslator.Translate(xamlReader);
            if (result.Errors.Count == 0)
            {
                StringBuilder sb = new StringBuilder();
                using (XmlWriter xmlWriter = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }))
                {
                    using (XamlXmlWriter writer = new XamlXmlWriter(xmlWriter, result.Output.SchemaContext))
                    {
                        XamlServices.Transform(result.Output, writer);
                    }
                }
                translatedWorkflowString = sb.ToString();
            }
            else
            {
                throw new InvalidOperationException("Translation errors");
            }
        }

        return XElement.Parse(translatedWorkflowString);
    }
0
On

I don't know if it is too late, but I was having the same issue even with the latest SharePoint Server 2013 upgrade.

What I did is to compare the "workflow.xaml" file from a SharePoint Designer workflow (after having saved it as a template into the Site Assets library) with the "workflow.xaml" generated from within Visual Studio 2013. What I found and what resolved my issue is to add these two attributes as a part of the Activity element.

xmlns:local

="clr-namespace:Microsoft.SharePoint.WorkflowServices.Activities"

xmlns:mwaw

="clr-namespace:Microsoft.Web.Authoring.Workflow;assembly=Microsoft.Web.Authoring"