I've a C# WPF application that throws following error message and crashes:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I then added following exception handlers in the code. And also added following line of code in the start of the method which was throwing above exception.
throw new System.AccessViolationException();
Exception handlers are now getting executed on clicking the app exe on my local machine when above exception occurs, but the app still crashes. I need to be able to prevent the app from crashing. Not sure how do I do that?
application.DispatcherUnhandledException += ApplicationDispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
AppDomain currentAppDomain = AppDomain.CurrentDomain;
currentAppDomain.UnhandledException += new UnhandledExceptionEventHandler
(UnhandledExceptionHandler);
Thanks.