Page 1 of 1

TROUBLESHOOTING: Attempted to read or write protected memory

Posted: Fri Apr 11, 2014 3:25 pm
by sparky2708
Does .NET Memory Profiler provide any help with troubleshooting the following .NET errors. Any pointers on how to troubleshoot these issues?:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()

Re: TROUBLESHOOTING: Attempted to read or write protected me

Posted: Tue Apr 15, 2014 8:12 pm
by Andreas Suurkuusk
.NET Memory Profiler does not provide any direct help with troubleshooting an AccessViolationException. The access violation you get seems to occur in native code. I recommend that you run your program under debugger with unmanaged debugging enabled. If you are able to reproduce the error when running under the debugger, you should be able to find the native code that causes the exception (if you have the native symbols available). Hopefully the access violation is easily explained when you have found the location. Unfortunately, an access violation can also be caused by memory that has been corrupted by totally unrelated code, in which case the error can be very hard to find.