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

前端之家收集整理的这篇文章主要介绍了导致.NET的访问冲突错误的常见原因前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在寻找.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.

推荐的:

GFlagsApplication Verifier

原文链接:https://www.f2er.com/vb/255284.html

猜你在找的VB相关文章