Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserialising a LayoutDocumentFloatingWindow gives XML error

See original GitHub issue

When deserialising this saved layout:

<?xml version=""1.0"" encoding=""utf-16""?>
  <RootPanel Orientation=""Horizontal"">
    <LayoutDocumentPaneGroup Orientation=""Vertical"">
      <LayoutDocumentPane Id=""510dd237-81be-4b7d-acbf-97173c64122f"">
        <LayoutDocument Title=""Test Mymenu 1"" IsSelected=""True"" ContentId=""TestMymenu"" LastActivationTimeStamp=""11/20/2019 16:55:31"" />
      <LayoutDocumentPane Id=""e08ee504-1b6c-4c14-9987-ee6ea0f8d03e"">
        <LayoutDocument Title=""Mymenu 1"" IsSelected=""True"" ContentId=""Mymenu"" LastActivationTimeStamp=""11/20/2019 16:55:03"" />
        <LayoutDocument Title=""Test Mymenu 2"" IsSelected=""True"" ContentId=""TestMymenu"" FloatingLeft=""115"" FloatingTop=""32"" FloatingWidth=""136"" FloatingHeight=""39"" LastActivationTimeStamp=""11/20/2019 16:49:17"" />
  <TopSide />
  <RightSide />
  <LeftSide />
  <BottomSide />
      <LayoutDocument Title=""Dev AIX 1"" IsSelected=""True"" IsLastFocusedDocument=""True"" ContentId=""DevAix"" FloatingLeft=""2573"" FloatingTop=""291"" FloatingWidth=""1079"" FloatingHeight=""769"" LastActivationTimeStamp=""11/20/2019 16:55:44"" PreviousContainerId=""e08ee504-1b6c-4c14-9987-ee6ea0f8d03e"" PreviousContainerIndex=""1"" />
      <LayoutDocument Title=""Gorgias Browser"" IsSelected=""True"" ContentId=""Gorgias Browser:"" FloatingLeft=""2568"" FloatingTop=""8"" FloatingWidth=""1141"" FloatingHeight=""750"" LastActivationTimeStamp=""11/20/2019 16:55:40"" PreviousContainerId=""e08ee504-1b6c-4c14-9987-ee6ea0f8d03e"" PreviousContainerIndex=""1"" />
      <LayoutDocument Title=""Fees And Rates"" IsSelected=""True"" ContentId=""FeesAndRates"" FloatingLeft=""1950"" FloatingTop=""9"" FloatingWidth=""605"" FloatingHeight=""866"" LastActivationTimeStamp=""11/20/2019 16:55:31"" PreviousContainerId=""510dd237-81be-4b7d-acbf-97173c64122f"" PreviousContainerIndex=""1"" />
  <Hidden />

I get the error “There is an error in xml document (23,7)”

This is the start of the LayoutDocumentFloatingWindow data.

I have gone back to 3.6.2 and it works. It stops working at version 4.0.0 Looking at the code, there is significant difference in this area between the versions.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

markoliver288commented, Jun 25, 2020

Its not pretty code, but it does work:

        /// <summary>Some stored layouts may not be compatible with the version required now. So update it.</summary>
        /// <param name="layoutSchema">The layout of the displays</param>
        /// <returns>The <see cref="string"/> that contains adjusted layout</returns>
        private string AddBackwardsCompatabilityTagsIntoDisplayLayout( string layoutSchema )
            XDocument xLayout = XDocument.Parse( layoutSchema );
            XElement root = xLayout.Root;
            var allInvalidDocuments = root.Elements( @"FloatingWindows" )
                                    .Elements( @"LayoutDocumentFloatingWindow" )
                                    .Elements( @"LayoutDocument" ).ToList();
            if ( allInvalidDocuments.Any() )
                var newFloatingWindowsRoot = new XElement( "FloatingWindows" );
                foreach ( XElement invalidDocumentItem in allInvalidDocuments )
                    XElement newParentParentParent = new XElement( "LayoutDocumentFloatingWindow" );
                    XElement newParentParent = new XElement( "LayoutDocumentPaneGroup" );
                    newParentParent.SetAttributeValue( "Orientation", "Horizontal" );
                    XElement newParent = new XElement( "LayoutDocumentPane" );
                    newFloatingWindowsRoot.Add( newParentParentParent );
                    newParentParentParent.Add( newParentParent );
                    newParentParent.Add( newParent );
                    newParent.Add( invalidDocumentItem );

                //Now put them in the document correctly.
                xLayout.Root.Element( @"FloatingWindows" ).ReplaceWith( newFloatingWindowsRoot );

            string adjustedLayout = $@"{xLayout.Declaration}{Environment.NewLine}{xLayout}";
            return adjustedLayout;

Because of this change with LayoutDocuments, we had to tweak some of our templates, and any code that referenced LayoutDocuments required checking too. All of that code is bespoke to us though, so no point sharing here.

Dirkster99commented, Jun 25, 2020

Looks pretty nice to me - thanx for sharing

Read more comments on GitHub >

github_iconTop Results From Across the Web

InvalidOperationException when deserializing layout #59
Hi, when attempting to deserialize a saved layout from XML, I get the following exception: System.InvalidOperationException: 'Collection was ...
Read more >
AvalonDock Not rendering layout when using default ...
I have come across this issue and the problem is not the callback. It is unnecessary. The method to Deserialize will NOT work...
Read more >
XmlSerializer Class (System.Xml.Serialization)
Serializes and deserializes objects into and from XML documents. The XmlSerializer enables you to control how objects are encoded into XML.
Read more >
ArduinoJson: Efficient JSON serialization for embedded C++
ArduinoJson is a JSON library for Arduino, IoT, and any embedded C++ project. It supports JSON serialization, JSON deserialization, MessagePack, streams, ...
Read more >
Floating Layout panel serialization
Hello guys. There is a bug in the serialization of the position of LayoutPanel when they are floating . Start please application in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found