I have an issue with an external component that throws System.AccessViolationException
. The problem is that this component is a plugin of Internet Explorer/Edge used in System.Windows.Forms.WebBrowser
. So navigating to a special webpage triggers the web browser to load an ActiveX
plugin which sometimes fails. In the case of this exception, my whole application is terminated. I am able to catch the exception by enabling
legacyCorruptedStateExceptionsPolicy
in config and setting up
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
in my Program.cs, but the IsTerminating
flag is set and my app will crash afterward. Since I have several windows opened using Form.Show
and one of it is hosting the WebBrowser control: is there a way to catch this exception within my Form controlling the web browser and just terminate this one? So the rest of the application is still alive? Or even better: is it possible to handle the exception, navigate to a blank page displaying just a short error message?
Thank you very much for your help!