Exception when deserializing rafting document window

Docking/MDI for WPF Forum

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

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

<Window x:Class="SerializeTest.MainWindow"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:actiprodocking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
   Title="MainWindow" Height="350" Width="525">
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="25"/>
         <RowDefinition Height="*"/>
      </Grid.RowDefinitions>

      <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:SplitContainer>
            <actiprodocking:Workspace>
               <actiprodocking:TabbedMdiHost IsCloseButtonOnTab="True" IsImageOnTab="True">
                  <actiprodocking:SplitContainer Orientation="Vertical">
                     <actiprodocking:TabbedMdiContainer>
                        <actiprodocking:DocumentWindow Name="doc1" Title="1"/>
                        <actiprodocking:DocumentWindow Name="doc2" Title="2"/>
                        <actiprodocking:DocumentWindow Name="doc3" Title="3"/>
                     </actiprodocking:TabbedMdiContainer>
                  </actiprodocking:SplitContainer>
               </actiprodocking:TabbedMdiHost>
            </actiprodocking:Workspace>
         </actiprodocking:SplitContainer>
      </actiprodocking:DockSite>
   </Grid>
</Window>

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

      public MainWindow()
      {
         InitializeComponent();

         _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 :)

Thanks,
Geir

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.