WPF应用程序中的随机访问冲突异常 [英] Random Access Violation Exception in WPF Application

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

问题描述



在WPF应用程序上运行回归测试时,我遇到了奇怪的问题.

我每次都获得具有不同堆栈跟踪的AccessViolationException.

首先:

Hi,

I m facing weird problem while running regression tests on my WPF Application.

I m getting AccessViolationException with different stacktraces each time.

First :

Message :Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
StackTrace :   at MS.Win32.PresentationCore.UnsafeNativeMethods.MILUnknown.Release(IntPtr pIUnkown)
   at MS.Win32.PresentationCore.UnsafeNativeMethods.MILUnknown.ReleaseInterface(IntPtr& ptr)
   at System.Windows.Media.SafeMILHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
   at System.Runtime.InteropServices.SafeHandle.Finalize()
Source :PresentationCore
Type : System.AccessViolationException.


第二:


Second :

Message :Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
StackTrace :   at MS.Win32.PresentationCore.UnsafeNativeMethods.IMILBitmapEffect.GetOutput(SafeHandle THIS_PTR, UInt32 uiIndex, SafeMILHandle pContext, BitmapSourceSafeMILHandle& ppBitmapSource)
   at System.Windows.Media.Effects.BitmapEffect.GetOutput(SafeHandle unmanagedEffect, Int32 index, BitmapEffectRenderContext context)
   at System.Windows.Media.Effects.BitmapEffect.GetOutput(BitmapEffectInput input)
   at System.Windows.Media.Effects.BitmapEffectState.GetEffectOutput(Visual visual, RenderTargetBitmap& renderBitmap, Matrix worldTransform, Rect windowClip, Matrix& finalTransform)
   at System.Windows.Media.Effects.BitmapEffectVisualState.RenderBitmapEffect(Visual visual, Channel channel)
   at System.Windows.Media.Effects.BitmapEffectContent.ExecuteRealizationsUpdate()
   at System.Windows.Media.RealizationContext.RealizationUpdateSchedule.Execute()
   at System.Windows.Media.MediaContext.Render(ICompositionTarget resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Main()
Source :PresentationCore
Type :System.AccessViolationException


在应用程序事件日志中,我找到了以下条目:
1.分派器处理已暂停,但消息仍在处理中.
2.错误的应用程序****.exe,版本1.0.0.*,戳记4c08d288,错误的模块wpfgfx_v0300.dll,版本3.0.6920.1427,戳记488f3056,调试? 0,故障地址0x0012ec36.

我的应用程序从另一个线程使用Dispatcher来更改控件的值,启用-禁用这些控件,更改可见性等,这些都可以在一秒钟内多次运行.

请让我知道是否有人遇到过这个问题?

预先感谢,
-Prasad


In Application Event Log I found following entries :
1. Dispatcher processing has been suspended, but messages are still being processed.
2. Faulting application ****.exe, version 1.0.0.*, stamp 4c08d288, faulting module wpfgfx_v0300.dll, version 3.0.6920.1427, stamp 488f3056, debug? 0, fault address 0x0012ec36.

My Application uses Dispatcher from another thread, to change the values of the controls , enable - disable those, change visibility etc., the thred is run multiple times in a second.

Please let me know if anybody has faced this problem?

Thanks in advance,
-Prasad

推荐答案

我也遇到过类似的问题(尝试读取或写入受保护的内存.这通常表明其他内存已损坏.")但这是在正常" winforms应用程序中,而不是WPF.

我追踪到它与数据库连接未正确关闭有关.我/我正在使用SQL Server CE.

从未有过使用普通" SQL Server(仅CE)的问题.

实际上这是一个很大的问题,我考虑过从CE切换到另一个数据库解决方案,但是经过大量工作,我发现问题已经解决了(无论如何还是99%)

根本不知道这有什么帮助,但是...
I''ve had a similar problem ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt.") But it was in a "normal" winforms application, not WPF.

I traced it down to have something to do with db connections not being closed properly in my DB layer. I was/am using SQL Server CE.

Have never had this problem with the "normal" SQL Server - only CE.

It was actually so big a problem that I considered switching from CE to another DB solution, but after a lot of work, I got it sorted out (well 99% anyway)

Don''t know if this is any help at all, though...


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

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