【问题标题】:FatalExecutionEngineError when closing WPF UserControl containing WebBrowser关闭包含 WebBrowser 的 WPF UserControl 时出现 FatalExecutionEngineError
【发布时间】:2016-04-21 15:13:31
【问题描述】:

我有以下基本 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>

当我尝试关闭包含用户控件的选项卡时,出现以下错误:

托管调试助手“FatalExecutionEngineError”检测到 'Some.vshost.exe' 中的问题。

附加信息:运行时遇到致命错误。这 错误地址位于线程 0x3bd0 上的 0x7ba6a66f。错误 代码是 0x80131623。此错误可能是 CLR 或 用户代码的不安全或不可验证部分。这个的常见来源 错误包括 COM-interop 或 PInvoke 的用户编组错误,其中 可能会损坏堆栈。

我尝试调用WebBrowser.Dispose(),但它返回相同的错误

【问题讨论】:

    标签: c# .net wpf webbrowser-control


    【解决方案1】:

    我们遇到了同样的问题。我们尝试手动处理控件,但问题仍然存在。最后,我们使用了 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");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      • 1970-01-01
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多