0x80131623 Error on Tab Change, WebBrowser Issue?

2

I'm having an issue with WPF's WebBrowser control. It's crashing with the titular error when I'm changing tabs - I think I know why (explained below), but I can't think of a way around it. I'm looking for either ideas on how I might reorganize the code to work correctly, or alternatives on what I'm using to achieve my goal.

The setup of the program is this: There are multiple tabs, containing Borders/Grids/etc. On one of these tabs, there is a Grid which has "Widgets", each containing a WebBrowser. These browsers are loading various locally-hosted pages with information for the user. To make the widgets look good, some code runs in the LoadCompleted event of the browser.

brow = new WebBrowser();
brow.LoadCompleted += wb_LoadCompleted;

(The wb_LoadCompleted function isn't important: the program will crash as it's being called, not during its execution.)

Also, when the user changes tabs, these Widgets have a Dispose function that's called.

brow.LoadCompleted -= wb_LoadCompleted;
brow.Source = null;

Now if the user opens the tab with these Widgets, then after the pages begin loading, but before they finish loading and call that event, the user switches tabs again, the program will crash once it attempts to call the wb_LoadCompleted event. I think this is happening because of the error described here. The handlers have been disposed because the tab changed, but the thread wants to call the handlers. In Visual Studio, if I place a break on the wb_LoadCompleted method, it'll be on that breakpoint when the error is thrown, so I think the program still knows what code it should be running, it just doesn't have permission to.

So far I've been unable to find a workaround or solution. Beyond code fix attempts, I've tried using different browser controls (Awesemonium, and a few others); while they work without this error, but they also balloon the size of our program distribution by 30 meg. That nearly doubles the size, and it's not feasible for us to do so. Any alternative browser control that works would be great, but it needs to be ~10 meg max.

I can also share some other code if you let me know what you need to see; however, I'd imagine this is more of a timing/placement/ordering issue than current code issue, if that makes sense.

e; Adding the full error text:

Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in -programpath-

Additional information: The runtime has encountered a fatal error. The address of the error was at 0x6bd5e4ad, on thread 0xa54. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

c#
wpf
multithreading
asked on Stack Overflow Apr 1, 2015 by Skyl3lazer • edited Apr 1, 2015 by Skyl3lazer

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0