内存访问冲突异常 [英] Memory Access Violation Exception

查看:144
本文介绍了内存访问冲突异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个小而烦人的问题.

我在Win Ultimate(7600)系统上使用VB 2010设计了应用程序,当我尝试调试应用程序时,它们都说"您试图读取或写入受保护的文件 ... Bla bla bla ".

你为什么会那样呢?

其他程序员给我的次要建议是添加一些东西,例如充当内存释放器的垃圾收集器,并将我所有的变量都更改为Null/Nothing,另一个是检查我在系统上的权限,并设置好它们对我的用户具有完全访问权限.

即使当我添加catch ex作为Exception部分时,它仍然会发生,哦,顺便说一句,它在我的代码中随机发生.

希望有人能帮助我.

谢谢.

Hey guys,

I have a small yet irritating problem.

I designed my apps using VB 2010 on a Win Ultimate (7600) system and when I try to debug the apps they all say that "You have attempted to read or write protected... Bla bla bla".

Why would you suppose that would be?

Minor suggestions what other programmers gave me was to add something such as a garbage collector which acts as a memory releaser and changing all my variables to Null/Nothing, The other one was to check out my permissions on the system, and well they are set to full access for my user.

Even when I add a catch ex as Exception part it still happens, oh by the way it happens randomly all over my code.

Hope someone could help me out though.

Thanks.

推荐答案

任何使用不安全或不受管理的代码都可以使您获得这种类型的异常.

当代码试图读取或写入尚未分配或无法访问的内存时,非托管或不安全代码中会发生访问冲突.这通常是由于指针的值错误而发生的.并非所有通过错误指针进行的读取或写入都会导致访问冲突,因此访问冲突通常表示通过错误指针发生了几次读取或写入操作,并且内存可能已损坏.因此,访问冲突几乎总是表示严重的编程错误.在.NET Framework 2.0版中,AccessViolationException清楚地标识了这些严重错误.

在完全由可验证托管代码组成的程序中,所有引用均为有效或为null,并且不可能发生访问冲突.仅当可验证的托管代码与非托管代码或不安全托管代码进行交互时,才会发生AccessViolationException.
Any use of unsafe or unmanaged code can get you that type of exceptions.

An access violation occurs in unmanaged or unsafe code when the code attempts to read or write to memory that has not been allocated, or to which it does not have access. This usually occurs because a pointer has a bad value. Not all reads or writes through bad pointers lead to access violations, so an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted. Thus, access violations almost always indicate serious programming errors. In the .NET Framework version 2.0, an AccessViolationException clearly identifies these serious errors.

In programs consisting entirely of verifiable managed code, all references are either valid or null, and access violations are impossible. An AccessViolationException occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.


这篇关于内存访问冲突异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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