I have a C# WPF app that display an error dialog with the error code 0xc0000005. I researched this error code and found that it is a access violation error and could be caused by several things including native code errors (p/invoke and 3rd party dlls). Restarting the app seems to clear the error but I want to be able to force the app to close when that error occurs. Since it is not a managed code exception it is not caught in the try catch blocks, is there any way to force the app to close when this error occurs?
Asked
Active
Viewed 2,145 times
1
-
This should normally bomb the app. What is preventing it from bombing? Post a screenshot if you can't describe it. – Hans Passant Apr 13 '11 at 00:10
-
I haven't been able to repro it but the error dialog comes up and the app seems to be running fine in the background. Once you close the dialog, though, it closes the app. – evanb Apr 13 '11 at 16:59
1 Answers
1
You can catch native exceptions in different way. Either using Win32Exception
or SEHException
exception class or using catch without any exception type specified as
try
{}
catch
{}
Refer this for details: Can you catch a native exception in C# code?
Use Environment.Exit(0);
to terminate your application.