)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to resolve the application crash when the LoadDockState fails in WinForms Docking Manager?

Platform: WinForms |
Control: DockingManager |
Published Date: February 4, 2015 |
Last Revised Date: December 4, 2019

Serailize or de-serialize

When the AppStateSerializer is used in the DockingManager to serialize or de-serialize the docking state, the application may crash due to the LoadDockState returning false.  To avoid this kind of application crash, the designer state of the DockingManager or previously working state should be loaded by using LoadDesignerDockState method. The following code example demonstrates the same.

C#

//Save dockstate.
m_Stream = new MemoryStream();
AppStateSerializer aser = new AppStateSerializer(SerializeMode.BinaryFmtStream, m_Stream);
this.dockingManager1.SaveDockState(aser);
aser.PersistNow();
//Load dock state.
m_Stream.Seek(0, SeekOrigin.Begin);
AppStateSerializer aser = new AppStateSerializer(SerializeMode.BinaryFmtStream, m_Stream);
this.dockingManager1.LoadDockState(aser);
//If LoadDockState returns false.
if (this.dockingManager1.LoadDockState(aser) == false)
{
    this.dockingManager1.ResumeLayout(true);
    this.dockingManager1.LoadDesignerDockState();
}

VB

'Save dockstate.
m_Stream = New MemoryStream()
Dim aser As New AppStateSerializer(SerializeMode.BinaryFmtStream, m_Stream)
Me.dockingManager1.SaveDockState(aser)
aser.PersistNow()
'Load dock state.
m_Stream.Seek(0, SeekOrigin.Begin)
Dim aser As New AppStateSerializer(SerializeMode.BinaryFmtStream, m_Stream)
Me.dockingManager1.LoadDockState(aser)
'If LoadDockState returns false.
If Me.dockingManager1.LoadDockState(aser) = False Then
    Me.dockingManager1.ResumeLayout(True)
    Me.dockingManager1.LoadDesignerDockState()
End If

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/DockingManager_LoadDockState-2014510522.zip

UG document link: https://help.syncfusion.com/windowsforms/dockingmanager/serialization

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon