Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2012 / 2013 AccessViolationException

When I run the project (F5) I receive the following exception in 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.

Stack trace reports

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()

I have never noticed receiving the same exception when running without debugger (CTRL+F5). This is a WPF project, but exception occurs before the App_ctor is executed, so this is external code, and my application code did not start to execute. This happens sporadically, sometimes it happens only once, and sometimes I run the project and get this message for several times in a roll. Then it does not pop up for 5-6 runs, and then starts again.

Anyone knows why is this happening? I have just installed clean W8.1 64 bit, VS2013 and TFS 2013 (although I had the same problem with W8 and VS2012, but not as often).

like image 977
Goran Avatar asked Oct 24 '13 23:10

Goran


People also ask

What is System AccessViolationException?

An AccessViolationException exception is always thrown by an attempt to access protected memory -- that is, to access memory that is not allocated or that is not owned by a process. Automatic memory management is one of the services that the common language runtime provides.


1 Answers

This issue appears to be fixed in a dot net framework update (4.5.2). https://connect.microsoft.com/VisualStudio/feedback/details/819552/visual-studio-debugger-throws-accessviolationexception

like image 136
Shiv Avatar answered Sep 18 '22 23:09

Shiv