不透明度=1%有时给出Win32Exception:没有足够的存储可用来处理此命令

本文关键字:存储 处理 命令 不透明度 Win32Exception | 更新日期: 2023-09-27 18:18:13

我们的一个WinForm给出了下面的Form.Show异常。窗体的不透明度设置为1%。我们观察到,如果我们将不透明度设置为100%,错误就会消失。错误通常发生在机器(不是应用程序)长时间运行而不重新启动时,通常在2天后。

异常详细信息如下:

System.ComponentModel.Win32Exception: Not enough storage is available to process this command
   at System.Windows.Forms.Form.UpdateLayered()
   at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmCreate(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
MessageNot enough storage is available to process this command
StackTrace   at System.Windows.Forms.Form.UpdateLayered()
   at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmCreate(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)SourceSystem.W indows.Forms

不透明度=1%有时给出Win32Exception:没有足够的存储可用来处理此命令

System.ComponentModel。Win32Exception:没有足够的存储空间来处理这个命令

这是一个非常低级的Windows错误,它通常表示内核内存池耗尽。这通常不会指出托管代码是问题的根源,尽管在Winforms应用程序中泄漏窗口句柄永远是很容易的。先检查一下,运行Taskmgr.exe,切换到Processes选项卡。查看+选择列并勾选句柄、用户对象和GDI对象。在程序运行时观察这些列。特别是,如果USER对象只是不断攀升,那么你的代码有一个可能触发此异常的bug。到目前为止,泄漏窗口句柄的最典型方法是使用controls . clear()或controls . remove(),并且忘记在您删除的控件上调用Dispose()方法。那些被移除的控制只会堆积在隐藏的"停车窗口"上,永远不会释放。

如果没有成功,那么你的机器就有问题了。视频驱动程序最有可能是问题的根源。它在透明度和不透明度属性中非常重要,它是视频适配器实现的效果。当然,如果您的程序立即出现这个异常,而不是在运行了一段时间后才出现,那么这是一个领先的指标。这一点从问题中看不出来。寻找驱动程序更新是合乎逻辑的下一步。

相关文章: