Reputation: 1099
How to handle System.AccessViolationException on WinRT app using C#
I see http://dotnetslackers.com/articles/net/All-about-Corrupted-State-Exceptions-in-NET4.aspx but does not apply on windows store app.
Upvotes: 0
Views: 721
Reputation: 7192
You probably don't want to handle an AccessViolationException: the state of your application is unknown and potentially corrupted, so there isn't much recovery action you can take.
There's probably a bug somewhere in the application that is resulting in the AccessViolationException (it could be in your code, but it could also be in the framework itself). Maybe you could catch the exception catch and log it somewhere so you can attempt to figure out what is wrong and fix the problem.
As http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx says:
an access violation usually indicates that several reads or writes have occurred through bad pointers, and that memory might be corrupted
Since memory may be corrupted, it probably isn't safe for your application to continue. Who knows what state is correct and what state is wrong?
Upvotes: 1