Exception when deserializing rafting document window

Docking/MDI for WPF Forum

Posted 14 years ago by Geir Schjorlien
Version: 10.2.0531
Platform: .NET 3.5
Environment: Windows Vista (32-bit)

Here is the source code for a small sample which shows my problem:

<Window x:Class="SerializeTest.MainWindow"
   Title="MainWindow" Height="350" Width="525">
         <RowDefinition Height="25"/>
         <RowDefinition Height="*"/>

      <Button Content="Save" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Click="SaveButton_Click"/>
      <Button Content="Load" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Margin="70,0,0,0" Click="LoadButton_Click"/>

      <actiprodocking:DockSite Grid.Row="1" x:Name="MyDockSite" CanDocumentWindowsEditTitles="True" CanDocumentWindowsClose="False" CanDocumentWindowsRaft="True" UseHostedRaftingWindows="False">
               <actiprodocking:TabbedMdiHost IsCloseButtonOnTab="True" IsImageOnTab="True">
                  <actiprodocking:SplitContainer Orientation="Vertical">
                        <actiprodocking:DocumentWindow Name="doc1" Title="1"/>
                        <actiprodocking:DocumentWindow Name="doc2" Title="2"/>
                        <actiprodocking:DocumentWindow Name="doc3" Title="3"/>

namespace SerializeTest
   public partial class MainWindow : Window
      private DockSiteLayoutSerializer _layoutSerializer;
      private string _layoutXml;

      public MainWindow()

         _layoutSerializer = new DockSiteLayoutSerializer();
         _layoutSerializer.SerializationBehavior = DockSiteSerializationBehavior.All;
         _layoutSerializer.DocumentWindowDeserializationBehavior =  DockingWindowDeserializationBehavior.AutoCreate;

      private void SaveButton_Click(object sender, RoutedEventArgs e)
         _layoutXml = _layoutSerializer.SaveToString(MyDockSite);

      private void LoadButton_Click(object sender, RoutedEventArgs e)
         _layoutSerializer.LoadFromString(_layoutXml, MyDockSite);
I get an AccessViolationException in the following situation:
. Run the app and drag one of the document windows outside the app main frame.
. Click the Save button.
. Dock the document window again.
. Click the Load button.

In a similar case, I save the layout to file and load it again in a "Window_Loaded" event handler. In this case I don't get the AccessViolationException but a MessageBox with the message: "Element already has a logical parent. It must be detached from the old parent before it is attached to a new one."

A bugfix or a workaround is greatly appreciated :)


Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Geir,

Thanks for reporting this issue, which has already been corrected for the next maintenance release.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.