【发布时间】:2012-02-20 13:47:28
【问题描述】:
我在我的 C#.net win 表单应用程序中遇到以下异常。
GDI+ 中出现一般错误。
在 System.Drawing.Graphics.CheckErrorStatus(Int32 状态)
在 System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height)
在 WeifenLuo.WinFormsUI.Docking.DockWindow.OnPaint(PaintEventArgs e)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,Int16 层,布尔 disposeEventArgs)
在 System.Windows.Forms.Control.WmPaint(消息&m)
在 System.Windows.Forms.Control.WndProc(Message&m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message&m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
最令人困惑的一点是,当应用程序加载表单(其中包含一些丰富的图形、WPF 工作等)时,它很少发生,可以说大约 90% 的时间表单加载成功。但它很少会被复制,而且只在某些机器上,在其他一些机器上,这种形式是 100% 的工作,并且永远不会遇到这个异常。
我不知道为什么会发生这种异常,因为它也没有显示导致异常的确切堆栈跟踪。如果有人知道如何处理它,请提出建议。
【问题讨论】:
-
该错误也可能是由
g.DrawString(text, font, x, y);引起的,其中x或y的值太大或太小。