Wednesday, October 2, 2013

C# Winform: Mouse Over Combobox Generate InvalidOperationException

C# Winform: Mouse Over Combobox Generate InvalidOperationException

This appears to be an error beyond my control. My WinForm application (C#
.NET Client Profile 4.0) is single threaded. By this, I mean the code I
wrote has only one thread. I understand that any WinForm GUI application
may have a background thread.
My application is used by about ten people, only two of them experience
the following exception.
When the users hoover their mouse over a combobox located on a standard
toolstrip, the correct behavior is that the combobox becomes in focus.
However, two users got the following exception:
System.InvalidOperationException: Object is currently in use elsewhere.
It looks that the exception is from background thread. Also, if I changed
the Widows 7 fancy themes to the Windows Classic theme, the error goes
away. But my user refuse to change his beloved theme.
Could you advise me on how to avoid this exception? I was thinking of
adding an event handler, handling move over event? I haven't try that yet.
Any advice is highly appreciated
This is the detailed exception message and stack trace.
***** Exception Text *******
System.InvalidOperationException: Object is currently in use elsewhere.
at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points,
FillMode fillMode)
at System.Drawing.Graphics.FillPolygon(Brush brush, Point[] points)
at
System.Windows.Forms.ToolStripComboBox.ToolStripComboBoxControl.ToolStripComboBoxFlatComboAdapter.DrawFlatComboDropDown(ComboBox
comboBox, Graphics g, Rectangle dropDownRect)
at
System.Windows.Forms.ComboBox.FlatComboAdapter.DrawFlatCombo(ComboBox
comboBox, Graphics g)
at System.Windows.Forms.ComboBox.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)

No comments:

Post a Comment