加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

导致.NET的访问冲突错误的常见原因

发布时间:2020-12-17 00:22:51 所属栏目:大数据 来源:网络整理
导读:我正在寻找.NET下的访问冲突错误的常见原因. 我到目前为止检查过的事情 – 对实现IDisposable的所有对象调用Dispose 检查COM对象调用中的有效参数 显式删除所有手动添加的事件处理程序 请勿明确调用GC.Collect / GC.WaitForPendingFinalizers 处理本机对象时
我正在寻找.NET下的访问冲突错误的常见原因.

我到目前为止检查过的事情 –

>对实现IDisposable的所有对象调用Dispose
>检查COM对象调用中的有效参数
>显式删除所有手动添加的事件处理程序
>请勿明确调用GC.Collect / GC.WaitForPendingFinalizers
>处理本机对象时添加和删除内存压力(位图等).(已添加)
>验证所有PInvoke调用的有效参数类型
>确保正确使用IntPtr,SafeHandle和HandleRef
>线程(线程安全,重入函数),正确使用等待句柄. (添加)
>确保应用程序和DLL都针对相同的平台(x86或x64)(应用程序和dll应该与COM对象的目标平台相同.)(已添加)

还有其他建议吗?

编辑 – 将崩溃转储分析移至不同的问题.

使用不安全或非托管代码可以获得这种类型的异常.

AccessViolationException:

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.

推荐的:

GFlags和Application Verifier

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读