TROUBLESHOOTING: Attempted to read or write protected memory

Use this forum for questions on how to use .NET Memory Profiler and how to analyse memory usage.
Post Reply
sparky2708
Posts: 4
Joined: Sat Jan 22, 2011 5:14 am

TROUBLESHOOTING: Attempted to read or write protected memory

Post by sparky2708 » Fri Apr 11, 2014 3:25 pm

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

Andreas Suurkuusk
Posts: 1029
Joined: Wed Mar 02, 2005 7:53 pm

Re: TROUBLESHOOTING: Attempted to read or write protected me

Post by Andreas Suurkuusk » Tue Apr 15, 2014 8:12 pm

.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.
Best regards,

Andreas Suurkuusk
SciTech Software AB

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests