"错误创建窗口句柄" [英] "Error Creating Window Handle"

查看:165
本文介绍了"错误创建窗口句柄"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在处理一个非常大的.NET WinForms的复合应用程序 - 不是CAB,但类似家庭长大的框架。我们正在运行在Citrix和RDP环境中的Windows Server 2003。

We're working on a very large .NET WinForms composite application - not CAB, but a similar home grown framework. We're running in a Citrix and RDP environment running on Windows Server 2003.

我们已经开始遇到随机的,很难reproduct错误创建窗口句柄的错误,这似乎是在我们的应用程序的老式句柄泄漏。我们正在大量使用的第三方控件(剑锋GridEX,Infralution VirtualTree和.NET魔术对接),我们做了很多动态加载和内容呈现的基础上在我们的数据库中的元数据。

We're starting to run into random and difficult to reproduct "Error creating window handle" error that seems to be an old fashion handle leak in our application. We're making heavy use of 3rd Party controls (Janus GridEX, Infralution VirtualTree, and .NET Magic docking) and we do a lot of dynamic loading and rendering of content based on metadata in our database.

有很多关于谷歌信息关于这个错误,但不是很多关于如何避免这方面的问题,扎实指导。

There's a lot of info on Google about this error, but not a lot of solid guidance about how to avoid issues in this area.

是否计算器社会有什么好的指导,我要构建手柄友好的WinForms应用程序?

Does the stackoverflow community have any good guidance for me for building handle-friendly winforms apps?

推荐答案

我已经找到了很多问题的用户界面不会卸载如预期中的WinForms。

I have tracked down a lot of issues with UIs not unloading as expected in WinForms.

下面是一些一般的提示:

Here are some general hints:

  • 的很多时间,控制将停留在使用,因为控件的事件未正确删除(工具提示提供给我们造成真正的大问题,在这里)或控件没有正确处理。
  • 使用'使用'周围的所有模式对话框块,以确保它们被布置
  • 还有一些控件属性,将强制创建的窗口句柄之前,有必要(例如设置TextBox控件的只读属性将强制控制得以实现)
  • 使用像的.Net内存分析器一个工具来获得所创建的类罪名。新版本的这个工具还将跟踪GDI和用户对象。
  • 尝试,以尽量减少你的用WIN API调用(或其他的DllImport调用)的。如果你确实需要互操作使用,尝试了使用/ Dispose模式就能正常工作了以这样的方式包装这些调用。
  • alot of the time, a control will stay in use because controls events are not properly removed (the tooltip provider caused us really large issues here) or the controls are not properly Disposed.
  • use 'using' blocks around all modal dialogs to ensure that they are Disposed
  • there are some control properties that will force the creation of the window handle before it is necessary (for example setting the ReadOnly property of a TextBox control will force the control to be realized)
  • use a tool like the .Net Memory profiler to get counts of the classes that are created. Newer versions of this tool will also track GDI and USER objects.
  • try to minimize your use of Win API calls (or other DllImport calls). If you do need to use interop, try to wrap these calls in such a way that the using/Dispose pattern will work correctly.

这篇关于"错误创建窗口句柄"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆