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

AccessViolationException thrown now and then
lilithinzion
Waldis
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