views:

566

answers:

3

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)

+1  A: 

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" 
Robert Vuković
where can you download this from.. i dont seem to have it on my machine.
ooo
Robert Vuković
+1  A: 

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.

Hans Passant
Do you have a link for the leak bug in .NET 2.0 SP1?
EricSchaefer
@eric - analysis is here: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/cedaa0f2-383c-4e61-92c0-c09123cb67cd/
Hans Passant
Thanks.........
EricSchaefer
A: 

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.

Joe Clancy