Win32Exception:操作成功地完成 [英] Win32Exception: Operation completed succesfully

查看:879
本文介绍了Win32Exception:操作成功地完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码崩溃与一个例外:

The following code crashes with an exception :

MyWindow wnd = new MyWindow();
wnd.Show(); //here an exception occurs

异常是相当奇怪,但据我所知它在.NET <错误/ p>

Exception is rather strange but as I understand its a bug in .net

System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
   at MS.Win32.UnsafeNativeMethods.GetDC(HandleRef hWnd)
   at System.Windows.Interop.HwndTarget..ctor(IntPtr hwnd)
   at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
   at System.Windows.Interop.HwndSource..ctor(HwndSourceParameters parameters)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.CreateSourceWindowDuringShow()
   at System.Windows.Window.SafeCreateWindowDuringShow()
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Window.Show()

mywindow的对象是与里面的一些矢量图形的窗口,但不会太大。此外,当10-20 mywindow的对象已被打开,已经关闭它发生。

MyWindow object is a window with some vector graphics inside, but not too much. Also, it happens when 10-20 MyWindow objects have been opened and closed already.

解决方案:原因是GDI objects.They的泄漏是在创造我的低级代码包含一个错误。所以,这个问题并没有关注对mywindow的对象。

推荐答案

它不会在WINAPI错误代码轰炸,实际的错误码是E_FAIL,一个COM错误代码。这是非常无益的诊断什么,这并不意味着什么比无法做到这一点,不知道为什么。怎样的GetDC()可以产生错误代码是很难猜,我怀疑它是环保的东西挂钩WINAPI功能。或许是类似远程桌面或屏幕记录器。不要试图在另一台机器上运行这一点。

It doesn't bomb on a winapi error code, the actual error code is E_FAIL, a COM error code. Which is very unhelpful to diagnose anything, it doesn't mean anything more than "couldn't do it, no idea why". How GetDC() can produce that error code is very hard to guess, I suspect it is environmental with something hooking the winapi function. Perhaps something similar to remote desktop or a screen recorder. Do try running this on another machine.

正常的原因的GetDC()失败是一个句柄泄漏。 Windows停止给人一种过程更加手柄时,它已经消耗了他们一万了。有些事情,你可以用的TaskMgr.exe诊断,进程选项卡。查看+选择列和蜱把手,用户对象和GDI对象。首先检查的进程列表,并确认你没有消耗很多人的过程。 GDI的总数对象在会话的所有进程是由会话池大小的限制。接下来运行您的程序,并保持眼睛为您的工艺价值。

The "normal" reason for GetDC() failure is a handle leak. Windows stops giving a process more handles when it has consumed 10,000 of them already. Something you can diagnose with TaskMgr.exe, Processes tab. View + Select Columns and tick Handles, USER Objects and GDI Objects. First check the list of processes and verify that you don't have a process that consumes a lot of them. The total number of GDI Objects for all processes in a session is limited by the session pool size. Next run your program and keep an eye on the values for your process.

这篇关于Win32Exception:操作成功地完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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