I have the following basic XAML:
<Window x:Class="SomeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<WebBrowser x:Name="webBrowser"></WebBrowser>
</Grid>
</Window>
When I'm trying to close the tab that contains the user control I'm getting the following error:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'Some.vshost.exe'.
Additional information: The runtime has encountered a fatal error. The address of the error was at 0x7ba6a66f, on thread 0x3bd0. 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.
I tried to call the WebBrowser.Dispose()
but it returns the same error
We had the same problem. We tried to dispose the control manually but the problem was still active. At the end we used the WindowsFormsHost component and WebBrowser from the System.Windows.Forms namespace.
<Window x:Class="SomeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="_webBrowserGrid>
</Grid>
</Window>
In the code:
var host = new System.Windows.Forms.Integration.WindowsFormsHost();
System.Windows.Forms.WebBrowser _webBrowser = new System.Windows.Forms.WebBrowser();
host.Child = _webBrowser;
this._webBrowserGrid.Children.Add(host);
_webBrowser.Navigate("http://www.google.com");
User contributions licensed under CC BY-SA 3.0