Question

On some computers, our Windows Forms application crashes every time when opening certain Forms with this call stack:

Object reference not set to an instance of an object.
   at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at DevExpress.XtraEditors.XtraForm.WndProc(Message& msg)
   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)
Was it helpful?

Solution

When the feature Automatically move pointer to the default button is enabled in Control Panel, application crashes in Form.OnVisibleChanged when Form's AcceptButton does not derive from Windows.Forms.Control.

This is clearly a bug in Windows Forms, the documentation doesn't say that IButtonControl AcceptButton must derive from Control.

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