469,287 Members | 2,426 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

"Error creating window handle." Exception

Hi All,
Sometimes my application crashes with the exception

Exception type: System.ComponentModel.Win32Exception
Message: Error creating window handle.

My Question to you guys are:
1. I am not able to find out the root cause of it. Can somebody help me out?
2. How can I find the total window handle count?
If I open crash dump and run the command !handle, it provides me 792 handle count. Further investigation (!DumpHeap -type System.Windows.Forms.NativeWindow and !DumpArray -details <address>) says there is a generation 3 System.Windows.Forms.NativeWindow class which is having 8419 HandleBuckets (System.Windows.Forms.NativeWindow+HandleBucket). If I add both of them, still they are lesser than 10k limit of handles.

Can some body gives any clue? Am I missing something to find out handle count?
I am using .NET 2.0 + C# and can not provide source of my application. This error does not happen every time and seems non replicable.

Thanks in Advance.
Feb 19 '09 #1
2 8625
229 Expert 100+
Are you using some P/Invoke Win32 methods to create handles yourself?

I remember I once had this error, when I made an override of CreateParams property, but it only occured in Win2k; while it worked fine in Xp and Vista.

Do you have the exception's stack trace to try to see where it happens?
Feb 19 '09 #2
Thanks for the reply,

The applicaition has used unmanaged code a lot (C/C++ --> Managed C++ --> C#). however, as far as UI part is concerned, it is largely in mananged code.
The application fails inside System.Windows.Forms.dll while doing some of the most stupid tasks, like
in "System.Windows.Forms.Timer.Start"
in "Controls.Visible = True"

I am uanble to find out exact handle count in my crash dump. Also not able to track those handles.
This is the stack trace from crash dump:

System_Windows_Forms_ni!System.Windows.Forms.Nativ eWindow.CreateHandle(System.Windows.Forms.CreatePa rams)
System_Windows_Forms_ni!System.Windows.Forms.Timer +TimerNativeWindow.EnsureHandle()
System_Windows_Forms_ni!System.Windows.Forms.Timer +TimerNativeWindow.StartTimer(Int32)
System_Windows_Forms_ni!System.Windows.Forms.Timer .set_Enabled(Boolean)
System_Windows_Forms_ni!System.Windows.Forms.Timer .Start()
Syncfusion_Shared_Base!Syncfusion.Windows.Forms.Mo useControllerDispatcher.ProcessMouseMove(System.Wi ndows.Forms.MouseEventArgs)
Syncfusion_Shared_Base!Syncfusion.Windows.Forms.Sc rollControllMouseControllerDispatcher.ScrollContro lMouseMoveHandled(System.Object, System.Windows.Forms.MouseEventArgs)
Syncfusion_Shared_Base!Syncfusion.Windows.Forms.Sc rollControl.OnScrollControlHandledMouseMove(System .Windows.Forms.MouseEventArgs)
Syncfusion_Shared_Base!Syncfusion.Windows.Forms.Sc rollControl.OnMouseMove(System.Windows.Forms.Mouse EventArgs)
Syncfusion_Grid_Windows!Syncfusion.Windows.Forms.G rid.GridControlBase.OnMouseMove(System.Windows.For ms.MouseEventArgs)
Syncfusion_Grid_Windows!Syncfusion.Windows.Forms.G rid.GridControlBaseImp.OnMouseMove(System.Windows. Forms.MouseEventArgs)
System_Windows_Forms_ni!System.Windows.Forms.Contr ol.WmMouseMove(System.Windows.Forms.Message ByRef)
System_Windows_Forms_ni!System.Windows.Forms.Contr ol.WndProc(System.Windows.Forms.Message ByRef)
Syncfusion_Shared_Base!Syncfusion.Windows.Forms.Sc rollControl.WndProc(System.Windows.Forms.Message ByRef)
Syncfusion_Grid_Windows!Syncfusion.Windows.Forms.G rid.GridControlBase.WndProc(System.Windows.Forms.M essage ByRef)
System_Windows_Forms_ni!System.Windows.Forms.Contr ol+ControlNativeWindow.OnMessage(System.Windows.Fo rms.Message ByRef)
System_Windows_Forms_ni!System.Windows.Forms.Contr ol+ControlNativeWindow.WndProc(System.Windows.Form s.Message ByRef)
System_Windows_Forms_ni!System.Windows.Forms.Nativ eWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)

[SP and IP removed for the sake of clarity]
Feb 19 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Arne Styve | last post: by
1 post views Thread by Arne | last post: by
5 posts views Thread by Grant Edwards | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.