Question:

C# .NET - Error creating window handle

by Guest44651  |  earlier

0 LIKES UnLike

So I'm working on a very large program, but I occasionally get this error:

System.ComponentModel.Win32Exception: Error creating window handle.

It ususally comes up before the program even loads up. I've already done some research, and the conscensus seems to be that this error means you have used up all of the 1000 window handlers that an application can use...

So my question: Is there a way to look up how many windows handlers a specific application is using? I know you can go to the Task Manager, and under performance, you can see the total number of handlers... but I'm trying to figure out a way to determine an exact (ish) number at any given time...

Or if anyone knows a way to set the limit higher than 1000, that would be great too...

And I would redesign the software to use less handlers in the first place, but its a huge program, and it would likely take a year or two to reprogram it... so I would rather not do that...

 Tags:

   Report

1 ANSWERS


  1. "Error Creating Window Handle" This is one of the more aggravating errors in Windows programming. I think even worse than a VB6 favorite “Object ~ does not exist.“ I got it today when loading a form that is part of a VS2003 app I converted to VS2005. It took me a while to get to the bottom of why this error was being thrown (during debugging and also on a client machine) since it's coming from Win32, not .NET.

    In my case, it turned out that the culprit had something to do with setting icons, though this wasn't obvious because I could step through even that section of code with no problems. The error was thrown after the form had run through it's load method and on it's way back to the line of code that instantiated the form. Oddly, it was method call that did not even need to be there, possibly an accidental copy/paste at some point. But it's been in the VS2003 version for a long time and has caused no problems. When I deleted the particular code (happy to have such an easy out!), everything worked again.

    So, in hindsight, it all makes perfect sense. VS2005 and .NET 2.0, as I have noted in previous posts (having learned the hard way), is much more sensitive about UI threading issues. This is a GOOD thing and has helped me clean up some code that VS2003 let me get away with (more lack of understanding than anything). Icons are image files - a.k.a. unmanaged objects. So even though I wasn't getting anything helpful regarding where the problem was coming from and what the problem was exactly, the clues were all there.

    ”Error Creating Window Handle” is a Win32 error, therefore the first thing I should have been looking at was any code that did anything with unmanaged items. I did actually think of that early on, but overlooked that particular method call and went on a wild goose chase for a while.

    http://www.Fix-pc-Master.com

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.