关闭包含 WebBrowser 的 WPF UserControl 时出现 FatalExecutionEngineError
FatalExecutionEngineError when closing WPF UserControl containing WebBrowser
我有以下基本条件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>
当我试图关闭包含用户控件的选项卡时,出现以下错误:
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.
我试图调用 WebBrowser.Dispose()
但它 returns 同样的错误
我们遇到了同样的问题。我们尝试手动处理控件,但问题仍然存在。最后,我们使用了 System.Windows.Forms 命名空间中的 WindowsFormsHost 组件和 WebBrowser。
<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>
代码中:
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");
我有以下基本条件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>
当我试图关闭包含用户控件的选项卡时,出现以下错误:
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.
我试图调用 WebBrowser.Dispose()
但它 returns 同样的错误
我们遇到了同样的问题。我们尝试手动处理控件,但问题仍然存在。最后,我们使用了 System.Windows.Forms 命名空间中的 WindowsFormsHost 组件和 WebBrowser。
<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>
代码中:
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");