NullReferenceException in Windows.FormsUnsafeNativeMethods.CallWindowProc in .NET 1.1

S

Stan Huff

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
 
S

SP

Stan Huff said:
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?

Check you are disposing all forms that you open in the application after
they are closed.

SP

Also, how can a PInvoke method
 
S

Stan Huff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top