I have a stack trace of a NullReferenceException and the only code in the
stack trace is from System.Window.Forms.
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmUpdateUIState(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.ParkingWindow.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
Can someone tell me how this can happen? Also, how can a PInvoke method
such as CallWindowProc ever raise this exception? One of our employees ran
into this using Windows XP embedded in a production facility. I can't be
sure of what was happening exactly when this occurred. Such exceptions are
automatically sent to me via email when they occur.
Thanks,
Stan
SP - 28 Jan 2006 04:43 GMT
>I have a stack trace of a NullReferenceException and the only code in the
> stack trace is from System.Window.Forms.
[quoted text clipped - 17 lines]
>
> Can someone tell me how this can happen?
Check you are disposing all forms that you open in the application after
they are closed.
SP
Also, how can a PInvoke method
> such as CallWindowProc ever raise this exception? One of our employees ran
> into this using Windows XP embedded in a production facility. I can't be
[quoted text clipped - 4 lines]
> Thanks,
> Stan
Stan Huff - 30 Jan 2006 16:23 GMT
I always include form constructions in "using" statements such as:
using (Form frm = new Form()) {
}
As such, I believe they are always being disposed immediately after use.
Stan
> >I have a stack trace of a NullReferenceException and the only code in the
> > stack trace is from System.Window.Forms.
[quoted text clipped - 32 lines]
> > Thanks,
> > Stan