Error in creating windows handle

拈花ヽ惹草 提交于 2019-12-25 00:36:27

问题


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 :)


回答1:


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.



来源:https://stackoverflow.com/questions/1831088/error-in-creating-windows-handle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!