Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered WF4.5 Rehosted Workflow Designer issue

  • Monday, August 20, 2012 9:01 PM
     
     

    Hi All,

    Using a custom rehosted Workflow Designer 4.5 (WD45) for editing old (4.0) xaml file will create me the following error:

    System.Xaml.XamlDuplicateMemberException: 'Symbol' property has already been set on 'Sequence'.

    I figure out that the following element cause this problem in the new 4.5 xaml file:

    <sads:DebugSymbol.Symbol
    xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger">dw1DOlxFbXB0eS54YW1sAA==</sads:DebugSymbol.Symbol>

    It looks like the secrete text generated by my rehosted WD45 such as
    dw1DOlxFbXB0eS54YW1sAA== is not ignored during writing changes in the model:
    mc:Ignorable="sap sap2010 sads"

    Presently, I made a simple workaround for this issue such as replacing this secrete text by empty text, each time when the model has been changed.

    Is this a bug or do I need to make some changes in the rehosted WD for 4.5 release?

    Thanks in advance

    Roman


    Roman Kiss, MVP Connected System Developer

All Replies

  • Monday, August 20, 2012 9:30 PM
    Moderator
     
     
    When are you hitting the exception, is it during saving the xaml file?
    Which APIs are you using for loading+saving the file?
    Tim
  • Monday, August 20, 2012 10:07 PM
     
      Has Code

    Thank Tim for your prompt response,

    I updated my rehosted Workflow Designer 4.0 which has been in the production for couple years to the new version 4.5 (recompiling and adding new features such as outlineview, etc.)

    Read only feature (for both versions) is working, when I made any change in the model, the following my handler is invoking:

    this.wd.ModelChanged += delegate(object source, EventArgs args)
    {
      this.wd.Flush();       // !!!
      this.IsDirty = true;
    };

    and the designer shows after that a System.Xaml.XamlDuplicateMemberException

    The designer is loaded via:
    this.wd.Text = this.GetCurrentXmlDocument;
    this.wd.Load();

    Note, that my workaroud is in the this.GetCurrentXmlDocument property where the value of the element sads:DebugSymbol.Symbol is deleted.

    Thanks

    Roman


    Roman Kiss, MVP Connected System Developer

  • Monday, August 20, 2012 10:56 PM
    Moderator
     
     Answered

    This sounds like a bug. I can't find any indication that it is a known issue in the bug database, so for now I am assuming it still happens in RTM. If so, due to timing I think it has a poor chance of being fixed in RTM. I would like to encourage you to submit a full repro for the issue via connect.microsoft.com anyway, as it should get fixed eventually.
    Tim

  • Monday, August 20, 2012 11:15 PM
     
     

    Thanks Tim

    Roman


    Roman Kiss, MVP Connected System Developer

  • Monday, September 17, 2012 9:41 AM
     
      Has Code

    Just for the record I also get this error after I upgraded to wf 4.5 and enabled the new designer features.

    Fix:

     XDocument xd = XDocument.Parse(xaml);
            XElement element = xd.XPathSelectElement("//*[local-name()='DebugSymbol.Symbol']");
            if(element != null)
            {
              element.SetValue(String.Empty);
            }
            
            using (MemoryStream stream = new MemoryStream())
            {
              XmlWriterSettings xws = new XmlWriterSettings();
              xws.OmitXmlDeclaration = true;
              xws.Indent = true; 
    
              using (XmlWriter writer = XmlWriter.Create(stream, xws))
              {
                xd.WriteTo(writer);
                writer.Flush();
                stream.Position = 0;
                activity = ActivityXamlServices.Load(stream);
              }
            }

    Trex


    • Edited by T Rex Monday, September 17, 2012 10:39 AM
    •  
  • Wednesday, October 17, 2012 2:41 AM
     
     

    Hi,

    we have also seen this error after upgrading our WF4.0 Designer to WF4.5 at PayGlobal.

    The workaround to empty the element below did work. I.e. the exception:

    System.Xaml.XamlDuplicateMemberException: 'Symbol' property has already been set on 'Flowchart' no longer occurs when we try to export a workflow.

    <sads:DebugSymbol.Symbol>dw1DOlxFbXB0eS54YW1sAA==</sads:DebugSymbol.Symbol>

    <sads:DebugSymbol.Symbol></sads:DebugSymbol.Symbol>

    Regards

    Mike Nooney

    Solution Architect, PayGlobal Ltd.


    • Edited by mnuni Wednesday, October 17, 2012 2:41 AM
    •  
  • Wednesday, November 07, 2012 9:54 AM
     
     Proposed

    Sorry, please see correct version:

    string ClearDebugInfo(string schema)
            {
                string symbolName="DebugSymbol.Symbol";

                XDocument xd = XDocument.Parse(schema);           
                XElement element = xd.Descendants().Where(e => e.Name.LocalName == symbolName).FirstOrDefault();           
                if (element != null)
                {
                    element.Remove();
                }
                else
                {
                    element = xd.Descendants().Where(e => e.Attributes().Where(a => a.Name.LocalName == symbolName).Count() > 0).FirstOrDefault();
                    if (element != null)
                        element.Attributes().Where(a=>a.Name.LocalName==symbolName).FirstOrDefault().Remove();
                }           

                return xd.ToString();
            }

    • Proposed As Answer by Martin Qian Wednesday, November 07, 2012 9:55 AM
    •  
  • Friday, April 19, 2013 9:49 AM
     
      Has Code
    When are you hitting the exception, is it during saving the xaml file?
    Which APIs are you using for loading+saving the file?
    Tim

    Hi Tim,

    I have encountered this issue with the latest .NET FW4.5 and WWF binaries. It's easy to reproduce it with the DesignerRehosting\Basic demo from the WF_WCF_Samples package, add a Button to the form and insert the following code:

            protected override void OnInitialized(EventArgs e)
            {
                base.OnInitialized(e);
                // register metadata
                (new DesignerMetadata()).Register();
    
                // create the workflow designer
                wd = new WorkflowDesigner();
                wd.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName = new FrameworkName(".NETFramework", new Version(4, 5));
                if(File.Exists("test.xaml")) {
                    string xaml = File.ReadAllText("test.xaml");
                    wd.Text = xaml;
                    wd.Load();
                }
                else {
                    wd.Load(new Sequence());
                }
                DesignerBorder.Child = wd.View;
                PropertyBorder.Child = wd.PropertyInspectorView;
         
            }
            WorkflowDesigner wd;
            private void button1_Click(object sender, RoutedEventArgs e) {
                wd.Flush();
                File.WriteAllText("test.xaml", wd.Text);
                MessageBox.Show("Completed");
            }

    Start the application, click the button to save the designed workflow (new empty Sequence), close the application and start it again (workflow will be loaded from a file this time). Click the button again: the designer shows "'Symbol' property has already been set on 'Sequence'" error.

    I have published a complete solution at https://docs.google.com/file/d/0B2-vYZiUvD4cY2dKdlBCMW04cjA/edit?usp=sharing

    Would you please review this project and provide additional information about it?

  • Tuesday, May 07, 2013 6:05 PM
     
     

    Since we have not received any answer on this after 3 weeks, we have submitted a bug report to Microsoft: https://connect.microsoft.com/VisualStudio/feedback/details/786503/

    I would ask every one who is facing the same issue to please upvote (see the green arrow at left) the aforementioned MS Connect item and feel free to post workaround solutions there, if any. Thanks for your cooperation in advance!


  • Tuesday, May 14, 2013 6:59 PM
     
     

    I can confirm this is a bug in workflow designer in .NET 4.5. This issue happens when you're using WorkflowDesigner.Load(), it doesn't happen on WorkflowDesigner.Load(string filename) as this overload will handle debug symbol properly. The later is used by workflow designer in Visual Studio and that's the reason why you'll never encounter this exact issue in VS.

    For those who run into this issue, there're several workarounds available. One is to manually remove the <sads:DebugSymbol.Symbol> element as Roman mentioned. A better solution is to use WorkflowDesigner.Load(string filename) when loading your workflow into the designer in the first place.

    The issue has been reported to the product team and hopefully will be fixed in the next release.

    If for whatever reason you cannot use any of the workarounds, please let us know why and we'll see if there're other alternatives.

  • Wednesday, May 29, 2013 7:17 PM
     
      Has Code

    what happens if we attempt to load this xaml with 

    MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(xaml));
    DynamicActivity workflowToRun = ActivityXamlServices.Load(ms) as DynamicActivity;
    where xaml is a string containing <sads:DebugSymbol.Symbol>?

    is it going to break? I don't mind start using Load(string) as opposed to Load() for design time purposes, as long as runtime executes this WF correctly.