"Error creating window handle." Exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rvarshney
    New Member
    • Feb 2009
    • 10

    "Error creating window handle." Exception

    Hi All,
    Sometimes my application crashes with the exception

    Exception type: System.Componen tModel.Win32Exc eption
    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.NativeWin dow and !DumpArray -details <address>) says there is a generation 3 System.Windows. Forms.NativeWin dow class which is having 8419 HandleBuckets (System.Windows .Forms.NativeWi ndow+HandleBuck et). 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.
  • vekipeki
    Recognized Expert New Member
    • Nov 2007
    • 229

    #2
    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?

    Comment

    • rvarshney
      New Member
      • Feb 2009
      • 10

      #3
      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.St art"
      in "Controls.Visib le = 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. NativeWindow.Cr eateHandle(Syst em.Windows.Form s.CreateParams)
      System_Windows_ Forms_ni!System .Windows.Forms. Timer+TimerNati veWindow.Ensure Handle()
      System_Windows_ Forms_ni!System .Windows.Forms. Timer+TimerNati veWindow.StartT imer(Int32)
      System_Windows_ Forms_ni!System .Windows.Forms. Timer.set_Enabl ed(Boolean)
      System_Windows_ Forms_ni!System .Windows.Forms. Timer.Start()
      Syncfusion_Shar ed_Base!Syncfus ion.Windows.For ms.MouseControl lerDispatcher.P rocessMouseMove (System.Windows .Forms.MouseEve ntArgs)
      Syncfusion_Shar ed_Base!Syncfus ion.Windows.For ms.ScrollContro llMouseControll erDispatcher.Sc rollControlMous eMoveHandled(Sy stem.Object, System.Windows. Forms.MouseEven tArgs)
      Syncfusion_Shar ed_Base!Syncfus ion.Windows.For ms.ScrollContro l.OnScrollContr olHandledMouseM ove(System.Wind ows.Forms.Mouse EventArgs)
      Syncfusion_Shar ed_Base!Syncfus ion.Windows.For ms.ScrollContro l.OnMouseMove(S ystem.Windows.F orms.MouseEvent Args)
      Syncfusion_Grid _Windows!Syncfu sion.Windows.Fo rms.Grid.GridCo ntrolBase.OnMou seMove(System.W indows.Forms.Mo useEventArgs)
      Syncfusion_Grid _Windows!Syncfu sion.Windows.Fo rms.Grid.GridCo ntrolBaseImp.On MouseMove(Syste m.Windows.Forms .MouseEventArgs )
      System_Windows_ Forms_ni!System .Windows.Forms. Control.WmMouse Move(System.Win dows.Forms.Mess age ByRef)
      System_Windows_ Forms_ni!System .Windows.Forms. Control.WndProc (System.Windows .Forms.Message ByRef)
      Syncfusion_Shar ed_Base!Syncfus ion.Windows.For ms.ScrollContro l.WndProc(Syste m.Windows.Forms .Message ByRef)
      Syncfusion_Grid _Windows!Syncfu sion.Windows.Fo rms.Grid.GridCo ntrolBase.WndPr oc(System.Windo ws.Forms.Messag e ByRef)
      System_Windows_ Forms_ni!System .Windows.Forms. Control+Control NativeWindow.On Message(System. Windows.Forms.M essage ByRef)
      System_Windows_ Forms_ni!System .Windows.Forms. Control+Control NativeWindow.Wn dProc(System.Wi ndows.Forms.Mes sage ByRef)
      System_Windows_ Forms_ni!System .Windows.Forms. NativeWindow.Ca llback(IntPtr, Int32, IntPtr, IntPtr)

      [SP and IP removed for the sake of clarity]

      Comment

      Working...