Question

I am seeing so odd behavior with DockPanelSuite when I close my documents. When I click the close 'X' at the top right of the documents the top document closes as expected (calls FormClosing event and Dispose() method of my derived DockContent class) but a small tab remains from the document. It is like the DockContent realizes the content should be discarded and ditches all the internal controls and the Form.Text is gone from the tab, and what remains is a tiny tab w/o any text.

Further attempts to close the tab again or click on the tab result in an 'ObjectDisposedException'.

Here are my environment specs:

Visual Studio 2008
DockPanelSuite AssemblyVersion("2.5.0.*")
Windows 7 x64

Below is a stacktrace. Stepping into the code I can see it bombs out when it tries to get the IDragSource.DragControl which is an instance of my already disposed control

(control being a derived DockContent class):

at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at WeifenLuo.WinFormsUI.Docking.DockPanel.DragHandlerBase.BeginDrag() in C:\Users\nick\Documents\Visual Studio 2008\Projects\DockPanel\WinFormsUI\Docking\DockPanel.DragHandler.cs:line 48
at WeifenLuo.WinFormsUI.Docking.DockPanel.DockDragHandler.BeginDrag(IDockDragSource dragSource) in C:\Users\nick\Documents\Visual Studio 2008\Projects\DockPanel\WinFormsUI\Docking\DockPanel.DockDragHandler.cs:line 699
at WeifenLuo.WinFormsUI.Docking.DockPanel.BeginDrag(IDockDragSource dragSource) in C:\Users\nick\Documents\Visual Studio 2008\Projects\DockPanel\WinFormsUI\Docking\DockPanel.DockDragHandler.cs:line 811
at WeifenLuo.WinFormsUI.Docking.DockPaneStripBase.OnMouseDown(MouseEventArgs e) in C:\Users\nick\Documents\Visual Studio 2008\Projects\DockPanel\WinFormsUI\Docking\DockPaneStripBase.cs:line 195
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at WeifenLuo.WinFormsUI.Docking.DockPaneStripBase.WndProc(Message& m) in C:\Users\nick\Documents\Visual Studio 2008\Projects\DockPanel\WinFormsUI\Docking\DockPaneStripBase.cs:line 246
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MosaicMaker.Program.Main() in C:\Users\nick\Documents\Visual Studio 2008\Projects\MosaicMaker\MosaicMaker\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Thanks in advance for help.

Besides this minor hiccup I am thoroughly pleased with the library.

Was it helpful?

Solution

Well, I found out my code was the source of the problem. The problem occurs when a control on a DockContent form throws an exception in its Dispose() method. The control does not dispose correctly, and for some reason the DockContent control does not close correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top