我到目前为止检查过的事情 –
>对实现IDisposable的所有对象调用Dispose
>检查COM对象调用中的有效参数
>显式删除所有手动添加的事件处理程序
>请勿明确调用GC.Collect / GC.WaitForPendingFinalizers
>处理本机对象时添加和删除内存压力(位图等).(已添加)
>验证所有PInvoke调用的有效参数类型
>确保正确使用IntPtr,SafeHandle和HandleRef
>线程(线程安全,重入函数),正确使用等待句柄. (添加)
>确保应用程序和DLL都针对相同的平台(x86或x64)(应用程序和dll应该与COM对象的目标平台相同.)(已添加)
还有其他建议吗?
编辑 – 将崩溃转储分析移至不同的问题.
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.
推荐的: