UnsafeNativeMethod Exception

G

Guest

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
(e-mail address removed)
 
J

Joey Calisay

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...
 

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