At random times in my C# WinForms app in .NET 1.1, I will get the following
stack trace:

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)

It seems to occur outside of any of my code so I can't handle the
exception. My main() is STA. Is there anything I can do to stop this or at
least handle the exception. The problem is that the exception even skips
over the AppDomain.CurrentDomain.UnhandledException event. I would think
that the exception would be occurring on the current AppDomain so it should
be handled by this event but it seems to skip this event. Is this exception
on a different AppDomain??? BTW, I also handle Application.ThreadException
but it doesn't go there either.

Thanks,

Ashton Hobbs
ashton@apexsql.com

Re: UnsafeNativeMethod Exception by Joey

Joey
Thu Oct 21 00:17:55 CDT 2004

It is an error on the processing of windows messages and it resulted in your
code.
I would suggest that you attach an instance of devenv.exe in your running
application and then capture the exception the instance it is thrown so you
know which line contributes to the exception...

"Ashton" <Ashton@discussions.microsoft.com> wrote in message
news:3F3DEB47-08EA-4300-BDF9-078CF464307A@microsoft.com...
> At random times in my C# WinForms app in .NET 1.1, I will get the
following
> stack trace:
>
> 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)
>
> It seems to occur outside of any of my code so I can't handle the
> exception. My main() is STA. Is there anything I can do to stop this or
at
> least handle the exception. The problem is that the exception even skips
> over the AppDomain.CurrentDomain.UnhandledException event. I would think
> that the exception would be occurring on the current AppDomain so it
should
> be handled by this event but it seems to skip this event. Is this
exception
> on a different AppDomain??? BTW, I also handle
Application.ThreadException
> but it doesn't go there either.
>
> Thanks,
>
> Ashton Hobbs
> ashton@apexsql.com