Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AvalonDock.LayoutRoot doesn't know how to deserialize... #111

Closed
aelij opened this issue Jan 27, 2020 · 4 comments
Closed

AvalonDock.LayoutRoot doesn't know how to deserialize... #111

aelij opened this issue Jan 27, 2020 · 4 comments
Labels

Comments

@aelij
Copy link

aelij commented Jan 27, 2020

When trying to deserialize a layout, the following exception is thrown:

System.InvalidOperationException: There is an error in XML document (17, 14).
 ---> System.ArgumentException: AvalonDock.LayoutRoot doesn't know how to deserialize 
   at Xceed.Wpf.AvalonDock.Layout.LayoutRoot.ReadElement(XmlReader reader)
   at Xceed.Wpf.AvalonDock.Layout.LayoutRoot.ReadElementList(XmlReader reader, Boolean isFloatingWindow)
   at Xceed.Wpf.AvalonDock.Layout.LayoutRoot.ReadXml(XmlReader reader)
   at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)
   at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderLayoutRoot.Read1_LayoutRoot()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
   at Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer.Deserialize(TextReader reader)

Layout XML:

<LayoutRoot>
  <RootPanel Orientation="Horizontal">
    <LayoutAnchorablePane Id="3305ae34-d029-44f2-a5f1-de32a4e7c7bf" Name="Documents" DockWidth="200" />
    <LayoutDocumentPane>
      <LayoutDocument IsSelected="True" IsLastFocusedDocument="True" LastActivationTimeStamp="01/27/2020 07:52:18" />
      <LayoutDocument />
    </LayoutDocumentPane>
  </RootPanel>
  <TopSide />
  <RightSide />
  <LeftSide>
    <LayoutAnchorGroup PreviousContainerId="3305ae34-d029-44f2-a5f1-de32a4e7c7bf">
      <LayoutAnchorable CanHide="False" AutoHideWidth="200" AutoHideMinWidth="100" AutoHideMinHeight="100" Title="Documents" ContentId="DocumentTree" CanClose="False" CanFloat="False" />
    </LayoutAnchorGroup>
  </LeftSide>
  <BottomSide />
</LayoutRoot>

Looking at the stack on first-chance exception, the xmlReader is at EOF (NodeType=None) so the following method should check that condition:

private object ReadElement(XmlReader reader)

Note the same code worked just fine in the WPF Toolkit version.

@Dirkster99
Copy link
Owner

Hi, thanks for your feedback. Just to clearify your change request. Are you suggesting to change the 2nd if statement in private object ReadElement(XmlReader reader) as shown below:

if (reader.NodeType == XmlNodeType.EndElement || reader.NodeType == XmlNodeType.None)
{
    return null;
}

Please let me know if this should work for you. Thanx Dirk

Dirkster99 added a commit that referenced this issue Feb 3, 2020
@Dirkster99
Copy link
Owner

Hi,

I cannot directly verify your exakt problem unless you give me a Layout that I can use with a test application in the repository (eg. Save a sample layout with MLibTest).

Nethertheless, I've tried to triangulate your problem and found a possible fix in this branch:
Fix_Issue_111

Would you please test this branch and let me know whether this works for you? It is important that you test more than the error case because I received errors (when loading a layout) about the PreviousContainerId not being resolvable and I am not sure whether thats because:

  1. I manipulated the layout manually or
  2. whether this is a direct problem with the current fix candidate?

Dirkster99 added a commit that referenced this issue Feb 26, 2020
Fix #111 with AvalonDock.LayoutRoot doesn't know how to deserialize.
@aelij
Copy link
Author

aelij commented Mar 21, 2020

@Dirkster99 Sorry for not replying earlier. Your fix works, thanks a lot!! ❤️

@Dirkster99
Copy link
Owner

It was @scdmitryvodich fix that worked I was not able to pin this one (sadly) - so I only released it but thanks for the good feedback :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants