Cannot access a disposed object.\r\nObject name: 'fw'.

Docking/MDI for Windows Forms Forum

Posted 18 years ago by Ernst
The following exception happens when I dock/undock/rearrange tool windows a few times. I don't have object named 'fw' in my application so it must be UI Studio internal object. Here are the steps:

1) Create project with a docked Tool Window which contains DataGridView with few columns with tooltips.
2) Hover the mouse over a column header to get tooltip displayed.
3) Undock the Tool Window so that it floats.
4) Hover the mouse over a column header to get tooltip displayed again.
5) Dock the window back and move the mouse over it. There will be exception.

Cannot access a disposed object.\r\nObject name: 'fw'.

at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.ToolTip.get_CreateParams()
at System.Windows.Forms.ToolTip.CreateHandle()
at System.Windows.Forms.ToolTip.Hide(IWin32Window win)
at System.Windows.Forms.DataGridView.DataGridViewToolTip.Activate(Boolean activate)
at System.Windows.Forms.DataGridView.ActivateToolTip(Boolean activate, String toolTipText, Int32 columnIndex, Int32 rowIndex)
at System.Windows.Forms.DataGridViewCell.OnMouseLeaveInternal(Int32 rowIndex)
at System.Windows.Forms.DataGridView.OnCellMouseLeave(DataGridViewCellEventArgs e)
at System.Windows.Forms.DataGridView.UpdateMouseEnteredCell(HitTestInfo hti, MouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)" string

Comments (1)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Actually I'm not so sure that is our bug. I've seen the exact same thing happen with Microsoft's ToolStrip control in .NET 2.0. After long investigation into that, we found that they somehow attach the control's Tooltip to the parent window. The bug in their code seems to be that if the parent changes, the tooltip reference to the parent form still points to the old parent. In your case it was to a floating window that is closed and disposed. Therefore the exception happens. We have duplicated this with just standard .NET controls/Forms too in a similar scenario.

We were never able to find a workaround for this issue because Microsoft hides their tooltip implementation. You'll note that your stack shows only core .NET controls in it, and not ours, which is another reason why I believe this is the same issue. We had tried all kinds of things with the ToolStrip but nothing we tried seemed to be able to clear the reference to the old parent form. So we ended up having to abandon using tooltips with it.

So unfortunately since it is a bug with how Microsoft implemented tooltips in their controls, you might have to forego using their built-in tooltip support and do it manually with a ToolTip control yourself.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.