Question

I have created a .net 2.0 windows application. This application creates form controls dynamically. Now when I am trying to run the application, it is throwing an exception "Error in creating windows handle". After this, application gets hang and nothing happens. At the first time, form gets displayed properly. On a particular event I am trying to reload the same form, while that time I am getting this exception. Anybody knows how to get rid of this. Any kind of help would be great full :)

Was it helpful?

Solution

I struck an issue just like this recently.

There's a limit per process of just 10,000 handles - easy to reach if you're dynamically creating a complex UI.

To check if this is happening for you, use Task Manager - go to the Processes tab, turn on the columns for "USER Objects" and "GDI Objects". Then, reproduce the problem.

In my case, the USER Object count was hitting exactly 10,000 and then "boom".

If this is what's happening for you, you'll need to make sure that old controls are properly disposed before you create a new form. You might need to redesign to use less handles - this is what I needed to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top