Multimobile Development: Building Applications for any Smartphone
Random exceptions in Windows Forms app
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Brian Eng
GOOD ANSWER
We are working on a large project that has several owner-drawn controls and
interacts with a couple of COM components (not ActiveX controls). At
seemingly random times, we receive (usually) a NullReferenceException.
Occasionally, it is a "External component has thrown an exception".
Regardless of the type of exception, we get the following stack trace:

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 QA team has been unable to find a reproducable path. Any ideas?
Reply to this message...
Vote that this is a GOOD answer... (15 votes from other users already)
 
 
    
Sijin Joseph
GOOD ANSWER
Ensure that your windows form App and them COM compoenents are using
compatible Threading models. By default all winform apps use the STA
threading model. If your COM components are MTA threaded then you could such
kind of exceptions.

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

"Brian Eng" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> We are working on a large project that has several owner-drawn controls
and
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Brian Eng
GOOD ANSWER
Thanks for your reply. That is really interesting... Unfortunately, our
WinForms app and all COM components are STA. Any other ideas?

"Sijin Joseph" wrote:

[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Brian Eng
GOOD ANSWER
Ok, we are getting to the root of the problem. We are using Spy++ to view
the parked window handles that are being created by our application. It
seems that when you create a panel that is not initially visible, its child
controls are initially parked. When you then close the containing form,
those child controls are not properly disposed. Anyone seen this before?

"Brian Eng" wrote:

[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Charles Collins
GOOD ANSWER
I have an application that is throwing the same error, but only when run
through terminal server. We have yet to see it in any other instance and it
is totally random and sporadic. A solution to this issue would be greatly
welcomed here too.

"Brian Eng" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (1 vote from another user already)
 
 
    
Mike Gaffney (VIP)
GOOD ANSWER
I'm also having the same issue:
About 600+ users running .NET app. Users connect using Citrix Terminal
Services to a WIN 2003 Server. I can't repoduce this on my development PC.
This is only reproduced using Terminal Services.

Error:
Base Exception Stack Trace: 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)
Inner Exceptions (may be empty):

Reply to this message...
Vote that this is a GOOD answer... (6 votes from other users already)
 
 
 
System.IntPtr
System.NullReferenceException
System.Windows.Forms.ContainerControl
System.Windows.Forms.Control
System.Windows.Forms.NativeWindow
System.Windows.Forms.ScrollableControl




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734