尝试读取或写入受保护的内存 [英] Attempted to read or write protected memory

查看:58
本文介绍了尝试读取或写入受保护的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始看到在我的应用程序中的几个不同位置抛出了 AccessViolationException.它从未发生在我的开发电脑,我们的测试服务器上.它也只出现在我们的 2 台生产服务器中的 1 台上.因为它似乎只发生在我们的一台生产服务器上,所以我开始查看服务器上安装的 .net 框架版本.


我发现(出于某种奇怪的原因)有问题的生产服务器有 2.0 sp2、3.0 sp2 和 3.5 sp1,而其他生产服务器和测试服务器有 2.0 sp1.


我的应用只针对2.0框架,决定从生产服务器卸载所有框架版本,只安装2.0 sp1.到目前为止,我还没有能够重现这个问题.很有意思.

开发电脑:compact 2.0 sp2、compact 3.5、2.0 sp2、3.0 sp2、3.5 sp1测试服务器:2.0 sp1生产服务器 1:2.0 sp1生产服务器 2:2.0 sp2、3.0 sp2、3.5 sp1

现在,为什么我无法在装有 2.0 sp2 的开发电脑上重现该问题,我想不通.我听说有传言说这种访问冲突可能发生在一些使用远程处理的软件上,我的就是这样做的,但是当远程处理实际发生时,访问冲突从未发生过.我现在可以只使用 2.0 sp1,但我真的很想知道是否有人遇到过这个问题,以及他们是否找到了适用于较新版本框架的解决方法.

I've started seeing an AccessViolationException being thrown in my application a several different spots. It never occured on my development pc, our test server. It also only manifested itself on 1 of our 2 production servers. Because it only seemed to happen on one of our production servers, I started looking at the installed .net framework versions on the servers.


I found that (for some strange reason), the production server that was having problems had 2.0 sp2, 3.0 sp2, and 3.5 sp1, while the other production server and the test server had 2.0 sp1.


My app only targets the 2.0 framework, decided to uninstall all the framework versions from the production server and install only 2.0 sp1. So far I have not been able to reproduce the problem. Very interesting.

Development pc: compact 2.0 sp2, compact 3.5, 2.0 sp2, 3.0 sp2, 3.5 sp1 Test server: 2.0 sp1 Production server1: 2.0 sp1 Production server2: 2.0 sp2, 3.0 sp2, 3.5 sp1

Now, why I can't reproduce the problem on my development pc which has 2.0 sp2 on it, I can't figure out. I heard rumors that this access violation may happen on some software that utilizes remoting, which mine does, but the access violation never happends when remoting is actually occuring. I'm ok with using only 2.0 sp1 for now, but I'm really interested to know if anyone has had this issue, and if they found a workaround for newer versions of the frameowork.

以下是一些异常及其堆栈跟踪:

Here's a couple of the exceptions and their stack traces:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at ICSharpCode.TextEditor.TextArea.HandleKeyPress(Char ch)
   at ICSharpCode.TextEditor.TextArea.SimulateKeyPress(Char ch)
   at ICSharpCode.TextEditor.TextArea.OnKeyPress(KeyPressEventArgs e)
   at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
   at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
   at System.Windows.Forms.Control.WmKeyChar(Message& m)
   at System.Windows.Forms.Control.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)

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.RichTextBox.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)

推荐答案

我遇到了同样的问题.2.0 运行良好.安装最高 3.5 sp1 后,应用程序会出现访问冲突.

I had the same problem. 2.0 worked fine. after installing up to 3.5 sp1, application gets Access Violation.

安装了http://support.microsoft.com/kb/971030,我的问题是解决了,即使我没有使用 LCG.

installed http://support.microsoft.com/kb/971030 and my problem is solved, even though I am not using LCG.

这篇关于尝试读取或写入受保护的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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