Saturday, February 19, 2011

Window handle debugging in Winforms

I have a user that keeps getting this error. Is there a tool that does window handle counting that i can use to figure out why he keeps getting this error.

System.ComponentModel.Win32Exception: Error creating window handle. at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.Form.CreateHandle() at System.Windows.Forms.Control.get_Handle() at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

From stackoverflow
  • Maybe this could help:

    Unhandled exception Win32Exception,Error creating window handle

    CLR Debugger (DbgCLR.exe)

    on mine machine debugger is located at:

    "c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\GuiDebug\DbgCLR.exe" 
    ooo : where can you download this from.. i dont seem to have it on my machine.
    Robert Vuković : I am not sure. I got it with Visual Studio install. Maybe you should instal .NET SDK from http://www.microsoft.com/downloads/details.aspx?familyid=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en
  • The best counter I know is Taskmgr.exe. View + Select Columns and check "User objects", "Handle count" and "GDI Objects".

    The generic diagnostic is that you're leaking handles and consumed 10,000 of them. Beware of a handle leak bug in .NET 2.0 SP1 and .NET 3.5's Graphics.CopyFromScreen(), fixed in 3.5 SP1.

    EricSchaefer : Do you have a link for the leak bug in .NET 2.0 SP1?
    Hans Passant : @eric - analysis is here: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/cedaa0f2-383c-4e61-92c0-c09123cb67cd/
    EricSchaefer : Thanks.........
  • If the Form you are creating overrides WndProc(), be careful to ensure that it always calls base.WndProc() during the window creation process.

    I inadvertently omitted a call to base.WndProc() in my override, and got your stack trace.

0 comments:

Post a Comment