System.AccessViolationException:尝试读取或写入受保护的内存.这通常表明其他内存已损坏. [英] System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

查看:601
本文介绍了System.AccessViolationException:尝试读取或写入受保护的内存.这通常表明其他内存已损坏.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端计算机上收到随机AccessViolationException.我已经捕获了异常文本并将其粘贴在下面.不幸的是,我编写的代码并未发生此错误,而.NET试图在表单上绘制组框时似乎正在发生.任何帮助,将不胜感激.

System.AccessViolationException:尝试读取或写入受保护的内存.这通常表明其他内存已损坏.

在System.Drawing.SafeNativeMethods.Gdip.GdipDrawLineI(HandleRef图形,HandleRef笔,Int32 x1,Int32 y1,Int32 x2,Int32 y2)

在System.Drawing.Graphics.DrawLine(钢笔,Int32 x1,Int32 y1,Int32 x2,Int32 y2)

System.Windows.Forms.GroupBox.DrawGroupBox(PaintEventArgs e)上的

System.Windows.Forms.GroupBox.OnPaint(PaintEventArgs e)上的

System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,Int16层,布尔值disposeEventArgs)上的

System.Windows.Forms.Control.WmPaint(Message& m)上的

System.Windows.Forms.Control.WndProc(Message& m)上的

System.Windows.Forms.GroupBox.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)上的

霍尔,

请发布整个代码段,以便我们重现您的方案.在.NET应用程序中,通常我们不写/读内存,我看到了一些内存问题,这些问题通常是由错误的编码引起的.请阅读此线程有关OOM异常的信息.代码错误引发此错误.还可以查看本文关于如何使用调试器调查有关OOM异常的内存问题.


I receive random AccessViolationException on client machines.  I have captured the exception text and have pasted it below.  Unfortunately this error is not happening on code that I have written it appears to be happening when the .NET  is trying to draw a group box on the form.  Any help on this would be appreciated.

 

 

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)

解决方案

Hi Hall,

Please post out the whole code snippet so that we can reproduce your scenario. In .NET application, commonly we don't write/read memory, I have saw some memory issues which are commonly raised by incorrect coding. Please Read this thread about OOM exception. The code bug raises this error.  Also have a look at this article about how to investigate the memory issues about OOM exception by using debugger.


这篇关于System.AccessViolationException:尝试读取或写入受保护的内存.这通常表明其他内存已损坏.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆