我们面临的问题是,有时会发生“AccessViolationException”异常,导致一个简单的组合框绘制了白色背景和一个红色交叉图案覆盖在其上面。我们无法可靠地重现这个错误,它只是偶尔发生。
我们没有做任何特殊的事情,只是显示一个带有菜单、工具栏、主面板上的组合框和一些超链接控件的主窗口。
从堆栈跟踪来看,似乎是Windows Forms或GDI+中的一个错误。
我们没有做任何特殊的事情,只是显示一个带有菜单、工具栏、主面板上的组合框和一些超链接控件的主窗口。
从堆栈跟踪来看,似乎是Windows Forms或GDI+中的一个错误。
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipDrawLineI(HandleRef graphics, HandleRef pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2)
at System.Drawing.Graphics.DrawLine(Pen pen, Int32 x1, Int32 y1, Int32 x2, Int32 y2)
at System.Windows.Forms.GroupBox.DrawGroupBox(PaintEventArgs e)
at System.Windows.Forms.GroupBox.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.GroupBox.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)
GroupBox
控件的FlatStyle
属性 设置为 "System"。看起来错误发生在 WinForms 尝试在内部绘制 groupbox 时;如果你让系统绘制它,你将绕过 WinForms 实现和 GDI+。这至少会让你得到一个可工作的构建版本,以便在找出真正的罪魁祸首时部署。也许发布一些代码可以帮助我们解决问题? - Cody Gray