none
Intermittent Error Publishing Custom (Declarative) Activity RRS feed

  • Question

  • Hi,

    I am encountering the following error when trying to publish a custom declarative activity via a Console Application to my local Workflow Manager server (i.e. using 'Microsoft.Workflow.TestServiceHost.exe'):

    System.Xaml.XamlObjectWriterException: System.Xaml.XamlObjectWriterException: Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({http://schemas.microsoft.com/workflow/2012/07/xaml/activities}DynamicValue)'

    The exception occurs when I call a customised version of the WorkflowUtils.Translate method (borrowed from the Workflow Manager samples), that loads up the assembly containing the activity before attempting to translate it. I've confirmed that the assembly containing the activity is in the /bin folder of the Console App and is being loaded by the Translate method.

    The annoying thing is I have a different Console App in the same solution, set up in exactly the same way (same assembly / project references etc.), which can quite happily publish the activity!

    I've followed the recommendations provided by Steve Danielson in the following link (regarding 'Cannot create unknown type' errors), but with no joy: Workflow Manager - Cannot Create Unknown Type

    I have included the code for the customised 'Translate' method below, any help with this issue would be much appreciated!

    Thanks,

    Julian

    public static XElement Translate(string xamlFile, string localAssembly = "")
            {
                string translatedWorkflowString = null;
                XamlXmlReaderSettings settings = new XamlXmlReaderSettings();
    
                if (!String.IsNullOrWhiteSpace(localAssembly))
                {
                    Assembly wfActivityAssembly = Assembly.LoadFile((Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + localAssembly));
                    settings.LocalAssembly = wfActivityAssembly;
                }
    
                using (XamlReader xamlReader = new XamlXmlReader(xamlFile, settings))
                {
                    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);
            }

    Thursday, January 15, 2015 10:47 AM

Answers

  • Hi,

    I tried creating yet another new Console Application and adding the necessary project / assembly references, and this time it worked! I don't know what was done differently but as this problem isn't easily reproducible I'll close this thread.

    • Marked as answer by Julian Monono Friday, January 16, 2015 5:55 PM
    Friday, January 16, 2015 5:55 PM