This project has moved. For the latest updates, please go here.

XmlLayoutSerializer - FileNotFountException

May 16 at 8:10 AM
I try to serialize/deserialize the Dockmanager Layout. I use .net 4.6.1 and get each time if i serialize the data an exception.
code:
  string xmlLayoutString = string.Empty;
  using (StringWriter fs = new StringWriter())
  {
    XmlLayoutSerializer xmlLayout = new XmlLayoutSerializer(frameworkElement);
    xmlLayout.Serialize(fs);
    xmlLayoutString = fs.ToString();
  }
message:
Additional Information: Die Assembly mit dem Anzeigenamen "Xceed.Wpf.AvalonDock.XmlSerializers" konnte im "LoadFrom"-Bindungskontext der AppDomain mit ID 1 nicht geladen werden. Fehlerursache: System.IO.FileNotFoundException: Die Datei oder Assembly "Xceed.Wpf.AvalonDock.XmlSerializers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

I defined a Property "ContentId" for each viewmodel.

Could anybody help?
Developer
May 17 at 3:11 PM
Hi,

v3.4 includes a fix in serialization with StringReader/StringWrtier.
In the meantime, try with StreamReader/StreamWriter :
private void OnSerialize( object sender, RoutedEventArgs e )
    {
      var layoutSerializer = new XmlLayoutSerializer( DockingManager );
      using( var writer = new StreamWriter( "AvalonDockSavedFile.txt" ) )
      {
        layoutSerializer.Serialize( writer );
      }
    }
 private void OnDeserialize( object sender, RoutedEventArgs e )
    {
      var layoutSerializer = new XmlLayoutSerializer( DockingManager );
      using( var reader = new StreamReader( "AvalonDockSavedFile.txt" ) )
      {
        layoutSerializer.Deserialize( reader );
      }
    }
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF
Jun 1 at 6:11 AM
It works but now I get a new exception during deserialize.
Exception thrown: 'System.NullReferenceException' in Xceed.Wpf.AvalonDock.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
the Default-Layout was load but deserialize crashed because LayoutElement.Root == null
Developer
Jun 6 at 8:32 PM
Hi,

The following doesn't crash with Toolkit v3.0 :
<Window x:Class="WpfApplication132.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication132"
        xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel>
    <xcad:DockingManager x:Name="_dockingManager"
                         MaxHeight="395"
                         AllowMixedOrientation="True"
                         BorderBrush="Black"
                         BorderThickness="1">
      <xcad:DockingManager.DocumentHeaderTemplate>
        <DataTemplate>
          <StackPanel Orientation="Horizontal">
            <Image Source="{Binding IconSource}"
                   Margin="0,0,4,0" />
            <TextBlock Text="{Binding Title}" />
          </StackPanel>
        </DataTemplate>
      </xcad:DockingManager.DocumentHeaderTemplate>
      <xcad:LayoutRoot x:Name="_layoutRoot">
        <xcad:LayoutPanel Orientation="Horizontal">
          <xcad:LayoutAnchorablePane DockWidth="200">
            <xcad:LayoutAnchorable ContentId="properties"
                                   Title="Properties"
                                   CanHide="False"
                                   CanClose="False"
                                   AutoHideWidth="240">
              <TextBlock Text="TEST" />
            </xcad:LayoutAnchorable>
          </xcad:LayoutAnchorablePane>
          <xcad:LayoutDocumentPaneGroup>
            <xcad:LayoutDocumentPane>
              <xcad:LayoutDocument ContentId="document1"
                                   Title="Document 1">
                <Button Content="Document 1 Content"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center" />
              </xcad:LayoutDocument>
              <xcad:LayoutDocument ContentId="document2"
                                   Title="Document 2">
                <TextBox Text="Document 2 Content"
                         AcceptsReturn="True" />
              </xcad:LayoutDocument>
            </xcad:LayoutDocumentPane>
          </xcad:LayoutDocumentPaneGroup >
          <xcad:LayoutAnchorablePaneGroup DockWidth="125">
            <xcad:LayoutAnchorablePane>
              <xcad:LayoutAnchorable ContentId="alarms"
                                     Title="Alarms"
                                     CanClose="True">
                <Button Content="TEST" />
              </xcad:LayoutAnchorable>
              <xcad:LayoutAnchorable ContentId="journal"
                                     Title="Journal">
                <RichTextBox>
                  <FlowDocument>
                    <Paragraph FontSize="14"
                               FontFamily="Segoe">
                      This is the content of the Journal Pane.
                      <LineBreak />
                      A
                      <Bold>RichTextBox</Bold> has been added here
                    </Paragraph>
                  </FlowDocument>
                </RichTextBox>
              </xcad:LayoutAnchorable>
            </xcad:LayoutAnchorablePane>
          </xcad:LayoutAnchorablePaneGroup>
        </xcad:LayoutPanel>

        <xcad:LayoutRoot.LeftSide>
          <xcad:LayoutAnchorSide>
            <xcad:LayoutAnchorGroup>
              <xcad:LayoutAnchorable Title="Agenda"
                                     ContentId="agenda">
                <TextBlock Text="Agenda Content"
                           Margin="10"
                           FontSize="18"
                           FontWeight="Black"
                           TextWrapping="Wrap" />
              </xcad:LayoutAnchorable>
              <xcad:LayoutAnchorable Title="Contacts"
                                     ContentId="contacts">
                <TextBlock Text="Contacts Content"
                           Margin="10"
                           FontSize="18"
                           FontWeight="Black"
                           TextWrapping="Wrap" />
              </xcad:LayoutAnchorable>
            </xcad:LayoutAnchorGroup>
          </xcad:LayoutAnchorSide>
        </xcad:LayoutRoot.LeftSide>
      </xcad:LayoutRoot>
    </xcad:DockingManager>


    <StackPanel Orientation="Horizontal"
                HorizontalAlignment="Center">
      <Button Content="Save AvalonDock"
              Margin="5"
              Padding="5"
              Click="OnSerialize" />
      <Button Content="Load AvalonDock"
              Margin="5"
              Padding="5"
              Click="OnDeserialize" />
    </StackPanel>
  </StackPanel>
</Window>
 public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }

    private void OnSerialize( object sender, RoutedEventArgs e )
    {
      var layoutSerializer = new XmlLayoutSerializer( _dockingManager );
      using( var writer = new StreamWriter( "AvalonDockSavedFile.txt" ) )
      {
        layoutSerializer.Serialize( writer );
      }
    }
    private void OnDeserialize( object sender, RoutedEventArgs e )
    {
      var layoutSerializer = new XmlLayoutSerializer( _dockingManager );
      using( var reader = new StreamReader( "AvalonDockSavedFile.txt" ) )
      {
        layoutSerializer.Deserialize( reader );
      }
    }
  }
――――
Get more controls, features, updates and technical support with Xceed Toolkit Plus for WPF