all groups > dotnet windows forms > january 2005 >
You're in the

dotnet windows forms

group:

UnsafeNativeMethods.CallWindowProc NullReferenceExceptions


Re: UnsafeNativeMethods.CallWindowProc NullReferenceExceptions Chris
1/7/2005 11:16:47 AM
dotnet windows forms:
I recently experienced an exception similar to this and determined that
we made calls to EnableVisualStyles in more than on place. When we
removed the duplicate calls, the exception went away.
This might be your problem, but it is worth a shot.

Chris
UnsafeNativeMethods.CallWindowProc NullReferenceExceptions Matt Garven
1/7/2005 4:54:11 PM
We are receiving error reports with NullReferenceExceptions from our users
with stacks like the following:

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)

---------

Our error reporter also takes a stacktrace at the time the exception was
handled, and the common element in all of them is Control.CreateHandle() and
the dreaded ParkingWindow.

I don't believe this is a threading issue, our app is mostly
single-threaded. The OnThreadException method is manually called in code by
the NativeWindow.Callback method.

An example of the callstack to the handler:

at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
at System.Windows.Forms.Control.WndProcException(Exception e)
at System.Windows.Forms.ControlNativeWindow.OnThreadException(Exception e)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr
wparam, IntPtr lparam)
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.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)
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.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.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)
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.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.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)
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32
dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32
x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef
hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle,
String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y,
Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef
hInst, Object pvParam)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.AccessibilityNotifyClients(AccessibleEvents
accEvent, Int32 childID)
at System.Windows.Forms.RadioButton.OnCheckedChanged(EventArgs e)
at Application.Namespace.Control.InitializeComponent() ... which is from
InitializeComponent() in one of our usercontrols for example.

I have seen several posts in this newsgroup describing similar problems, has
anyone had any resolution on them?

Regards,
Matt

Re: UnsafeNativeMethods.CallWindowProc NullReferenceExceptions Matt Garven
1/8/2005 11:43:19 PM
Hi Chris,

Thanks for the suggestion, however we don't use
Application.EnableVisualStyles at all.

Regards,
Matt

[quoted text, click to view]

Re: UnsafeNativeMethods.CallWindowProc NullReferenceExceptions Chris
1/10/2005 6:07:57 AM
Before Microsoft will respond, you must register on their site with
your e-mail address.
Re: UnsafeNativeMethods.CallWindowProc NullReferenceExceptions Matt Garven
1/10/2005 11:59:25 AM
This is still an ongoing issue for us.

We are told by Microsoft to seek support from Microsoft on these newsgroups,
but when someone posts a difficult question it goes unanswered.

So what are we supposed to do?

Regards,
Matt

[quoted text, click to view]

AddThis Social Bookmark Button