应用程序本身有 2000 行长,因此在此处粘贴代码是没有意义的,尤其是因为其中一位用户收到的异常没有提供任何提示,说明我的代码的哪一部分导致了问题。
顺便说一句,该应用程序只是一个带有 datagridview 的 Windows 窗体,通常显示不超过几百行数据和一些其他控件。在它崩溃之前,它加载 datagridview 每一行的单元格的速度非常慢。(但没有其他用户遇到过同样的问题。)
异常文本如下。有人可以查看它并告诉我它是否是由我的代码做错的事情引起的,或者可能与经历此异常的用户的特定设置不兼容?
我注意到下面的描述说内存已损坏。这是否意味着用户的计算机内存不好???
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipDrawRectangleI(HandleRef graphics, HandleRef pen, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.DrawRectangle(Pen pen, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Windows.Forms.ControlPaint.DrawFlatCheckBox(Graphics graphics, Rectangle rectangle, Color foreground, Brush background, ButtonState state)
at System.Windows.Forms.ControlPaint.DrawFlatCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics, Int32 x, Int32 y, Int32 width, Int32 height, ButtonState state)
at System.Windows.Forms.ControlPaint.DrawCheckBox(Graphics graphics, Rectangle rectangle, ButtonState state)
at System.Windows.Forms.CheckedListBox.OnDrawItem(DrawItemEventArgs e)
at System.Windows.Forms.ListBox.WmReflectDrawItem(Message& m)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.CheckedListBox.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)