我們的WinForm之一在Form.Show中給出了以下異常。表格的不透明度設置爲1%。我們觀察到,如果我們將不透明度設置爲100%,則錯誤消失。當機器(不是應用程序)長時間運行而沒有重新啓動時,通常會出現錯誤,一般在2天后。不透明度= 1%有時會給出Win32Exception:沒有足夠的存儲空間來處理此命令
異常詳情如下:
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
在我看來,真正的問題是在別的地方。如果您的應用程序運行很長時間,在發生錯誤之前,那麼很可能是某些資源沒有正確處理。垃圾收集器很好,但它本身並不能解決所有問題。 – ElmoVanKielmo
感謝ElmoVanKielmo的回覆。根據觀察,問題似乎只與不透明度有關。當我們做出1%的問題出現時,當我們把它做成100%時,就會出現問題。 – SantoshTupe
你說的是1%和100%,你嘗試過不同的價值嗎?因爲我猜100%不做任何事情,因爲它是默認設置... –