AccessViolationException thrown now and then

Hello,

I have an application which is stable for most of time but sometimes it unexpectedly crashes (usually after a few hours of running). I have never been able to reproduce it on my development machine.

The exception is always the same:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at AmaxSystem.Program.Main()

Is there any way how to determine where the exception occurs I am using a few 3rd party libraries and also some multithreading to keep UI responsive.

I have tried to catch it in Application.ThreadException and also in AppDomain.UnhandledException but still no luck


Answer this question

AccessViolationException thrown now and then

  • lilithinzion

    Once approach is to use the Microsoft's Debugging Tools for Windows: http://www.microsoft.com/whdc/devtools/debugging/default.mspx. These are designed for debugging on live machines, e.g., simple installation with a small footprint. You can use adplus to as a JIT debugger to capture the application's state (a dump) when an exception occurs on the live box. You can then load the dump on your developer box and debug it.
  • Waldis

    Hi Martin Susil
    Do you fixed your bugs above I have the same exception but I don't know why exception occur and when exception throwing Can you help me to solve this problem


  • RCQwerty

    Thank you, I will give it a try.

  • AccessViolationException thrown now and then