当我关闭文档时,我看到DockPanelSuite
的奇怪行为。当我点击文档右上角的关闭'X'
时,顶部文档会按预期关闭(calls FormClosing event and Dispose() method of my derived DockContent class)
,但文档中仍会留下一个小标签。就好像DockContent
意识到内容应该被丢弃并且丢弃所有内部控件并且Form.Text从选项卡中消失,剩下的是一个没有任何文本的小标签。
再次尝试再次关闭标签或点击标签会产生'ObjectDisposedException'.
以下是我的环境规范:
Visual Studio 2008
DockPanelSuite AssemblyVersion("2.5.0.*")
Windows 7 x64
下面是一个堆栈跟踪。进入代码时,我可以看到它在尝试获取IDragSource.DragControl
时发生爆炸,这是我已经处置的控件的实例
(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()
提前感谢您的帮助。
除了这个小小的打嗝,我对图书馆非常满意。
答案 0 :(得分:0)
好吧,我发现我的代码是问题的根源。当DockContent窗体上的控件在其Dispose()方法中引发异常时,会发生此问题。控件没有正确处理,并且由于某种原因DockContent控件没有正确关闭。