VS 2012 / 2013 AccessViolationException

15

当我运行项目(F5)时,在IDE中收到以下异常:

An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

堆栈跟踪报告

at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, Int32 wparam, IntPtr lparam)
at System.Windows.Forms.Form.UpdateWindowIcon(Boolean redrawFrame)
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at Microsoft.VisualStudio.HostingProcess.HostProc.RunParkingWindowThread()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

我从未注意到在没有调试器(CTRL + F5)的情况下运行时收到相同异常。这是一个WPF项目,但异常发生在执行App_ctor之前,因此这是外部代码,我的应用程序代码尚未开始执行。这种情况偶尔发生,有时只发生一次,有时我运行该项目并连续多次收到此消息。然后它不会再出现5-6次运行,然后又会重新开始。

谁知道为什么会发生这种情况?我刚刚安装了干净的W8.1 64位系统,VS2013和TFS 2013(尽管我在W8和VS2012上遇到了同样的问题,但不如现在频繁)。


请参考以下链接:see also,其中包含一个包含解决方法的评论。 - tolanj
我一直在尝试这个,这是我发现的:只有当方法是重写并且结构包含多个成员时才会发生,并且其中至少一个不是Int16、Int32、UInt16、UInt32、Single或Boolean。这并不能回答“为什么”,但提供了一些证据。VS 12.0.31101.00 Update 4 在 Win7/64 上。 - Duston
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接