{"id":2683,"date":"2022-08-30T15:26:54","date_gmt":"2022-08-30T15:26:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/06\/activex-in-webbrowser-in-winforms-crashing-whole-app-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:26:54","modified_gmt":"2022-08-30T15:26:54","slug":"activex-in-webbrowser-in-winforms-crashing-whole-app-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/activex-in-webbrowser-in-winforms-crashing-whole-app-collection-of-common-programming-errors\/","title":{"rendered":"ActiveX in WebBrowser in WinForms crashing whole app-Collection of common programming errors"},"content":{"rendered":"<p>I have a C# WinForms application, that has a WebBrowser control, which loads an html page in which is embedded a 3rd-party ActiveX object, which plays IPTV video. The Active X supplied by Exterity. I have also tried the VLC ActiveX control, which was even more unreliable, with the same symptoms. Same behavior on both XP and Win7.<\/p>\n<p>Intermittently the whole WinForms app exits. I already handle the ThreadException and UnhandledExcetion events thus:<\/p>\n<pre><code>[STAThread]\nstatic void Main(string[] args)\n{\n    \/\/set up global exception handling\n    Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);\n    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);\n    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\n<\/code><\/pre>\n<p>These events do not fire before the app exits; and believe me they do work, because they&#8217;ve been in place for a few years now, and have fired many times catching other errors (e.g. timeout database connection) (at which point i restart the whole app)! I see no entries in Windows Event View. My exe process just disappears.<\/p>\n<p>I&#8217;ve been reading up on AppDomains, and wondering whether i can put the WebBrowser control in a separate one to the main program\/Form; any advice appreciated.<\/p>\n<p>Or are there other ways i can handle, what i presume is, an exception that is going unhandled all the way to the top, at which point the process exits.<\/p>\n<ol>\n<li>\n<p>Trying to catch and ignore Access Violations is a recipe for introducing memory corruption that can corrupt your application&#8217;s data or settings. You&#8217;d be better off figuring out <em>why<\/em> the ActiveX control is crashing (e.g. use WinDBG) and addressing that.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-02-06 03:56:48. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have a C# WinForms application, that has a WebBrowser control, which loads an html page in which is embedded a 3rd-party ActiveX object, which plays IPTV video. The Active X supplied by Exterity. I have also tried the VLC ActiveX control, which was even more unreliable, with the same symptoms. Same behavior on both [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2683","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2683"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2683\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}