Short Version:
I have a WinForms app that uses a .NET 4.0 WebBrowser control to display an HTML page containing a Flash SWF file. The SWF file gets set up via some Javascript/jQuery/swf)iobject magic. Periodically, I run across a SWF file that will cause an AccessViolationException that stops my program. From what I can tell, this happens during the cleanup between showing one page and starting another (think automatic slideshow of web sites).
I've added AppDomain.CurrentDomain.UnhandledException and Application.ThreadException handlers, and my program still stops with a dialog on the screen. I want to prevent the dialog from showing up - how do I catch these types of exceptions and suppress them? I can restart my program or something - I can't have a dialog show up.
Gory Details:
I've got the exception handlers mentioned above, plust some try/catch logic around places where I'm invoking behavior in my WebBrowser DOM via InvokeScript(). But nothing I've got in place seems to get called.
The exception generated looks like this:
Faulting application name: MyProgram.exe, version: 1.0.0.0, time stamp: 0x50096c59
Faulting module name: Flash64_11_3_300_257.ocx, version: 11.3.300.257, time stamp: 0x4fc81d71
Exception code: 0xc0000005
Fault offset: 0x000000000022b1db
Faulting process id: 0x10d0
Faulting application start time: 0x01cd668d0db086f8
Faulting application path: C:\Users\AUser\AppData\Local\Apps\2.0\AWMVPDR4.HEJ\Z9EP5M32.MQ4\mmm...tion_2c82cc3ef3e7d3e9_0001.0000_6ffd6d2ca43477ab\MyProgram.exe
Faulting module path: C:\Windows\system32\Macromed\Flash\Flash64_11_3_300_257.ocx
Report Id: a9f6977f-d284-11e1-a447-00187d1f4237
and then this:
Application: MyProgram.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at System.Windows.Forms.UnsafeNativeMethods+IDispatch.GetIDsOfNames(System.Guid ByRef, System.String[], Int32, Int32, Int32[])
at System.Windows.Forms.HtmlDocument.InvokeScript(System.String, System.Object[])
at MyProgram.InvokeScriptExtension+<>c__DisplayClass2.<InvokeScript>b__0()
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)
at System.Threading.ExecutionContext.runTryCode(System.Object)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.WebBrowserBase.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.WebBrowser.WndProc(System.Windows.Forms.Message ByRef)
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
at MyProgram.Program.Main()
My challenge is to stop that exception from putting anything on the screen.