WebBrowser 控件在 Windows 10 时崩溃

WebBrowser control crashes on Windows 10

以下简短代码示例演示了某些页面的 WebBrowser 崩溃。问题是在 2015 年 12 月 26 日至 27 日全新安装 Windows 10 和 Visual Studio Community 2015 后出现的。之前安装 Windows 10 和 Visual Studio Community 2015. 同一个程序在另一台相同软件和操作系统的电脑上测试过同样的问题 发生。

单击 'Download 2' 成功从 Google 下载页面。

单击 'Download 1' 开始从 Bloomberg 下载,在页面的大部分内容可见后,弹出消息打开 "WindowsFormsApplication1.exe has triggered a breakpoint.",执行在第 "Application.Run(new Form1())" 行停止。有时直到滚动页面才会显示错误消息。在 IE11 上相同的 URL 下载没有问题,开发者工具/兼容性表明没有问题。将注册表中的 Webbrowser 仿真级别设置为 11001 没有任何区别。 WebBrowser1.ScriptErrorsSuppressed 没有区别。

如果单击 'continue',则会打开另一条消息,显示“WindowsFormsApplication1.exe 中 0x12C731C2 (Flash.ocx) 处未处理的异常:0xC0000602:发生快速失败异常。将不会调用异常处理程序 并且进程将立即终止。"

如果选择 'continue',则会打开另一条消息“在 WindowsFormsApplication1.exe 中的 0x00000000 抛出异常:0xC0000005:执行位置 0x00000000 的访问冲突。如果有此异常的处理程序, 该程序可以安全地继续。"

有什么可以解决问题的吗?

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public class Form1 : Form
{

    TextBox textBox1;
    TextBox textBox2;
    Button button1;
    Button button2;
    TableLayoutPanel table1;
    WebBrowser webBrowser1;

    public Form1()
    {

        textBox1 = new TextBox();
        textBox1.Width = 200;
        textBox1.Text = "http://www.bloomberg.com/energy";

        button1 = new Button();
        button1.Text = "Download 1";
        button1.Click += button1_Click;

        textBox2 = new TextBox();
        textBox2.Width = 200;
        textBox2.Text = "http://www.google.com";

        button2 = new Button();
        button2.Text = "Download 2";
        button2.Click += button2_Click;

        webBrowser1 = new WebBrowser();
        webBrowser1.Dock = DockStyle.Fill;
        webBrowser1.ScriptErrorsSuppressed = true;

        table1 = new TableLayoutPanel();
        table1.Dock = DockStyle.Fill;
        table1.RowCount = 3;
        table1.ColumnCount = 2;
        table1.Controls.Add(textBox1, 0, 0);
        table1.Controls.Add(button1, 1, 0);
        table1.Controls.Add(textBox2, 0, 1);
        table1.Controls.Add(button2, 1, 1);
        table1.Controls.Add(webBrowser1, 0, 2);
        table1.SetColumnSpan(webBrowser1, 2);

        this.Controls.Add(table1);
        this.WindowState = FormWindowState.Maximized;

    }

    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate(textBox1.Text);
    }

    private void button2_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate(textBox2.Text);
    }

}

static class Program
{
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        try
        {
            Application.Run(new Form1());
        } catch (Exception ex)
        {
            string msg = ex.Message;
        }
    }
}
}

我在 Windows 10 上的应用程序遇到了同样的问题,它在 Windows XP / Vista / 7 / 8 / 8.1 上工作正常,甚至在 Windows 的全新安装中也能正常工作10,但几个小时后它停止工作。

该应用程序是在 Visual Studio 2010 年开发的,并切换到 Visual Studio 2013 Ultimate 认为它可能是 Edge / ActiveX 不兼容 问题但没有:(

更新

此问题已在 Microsoft update 中修复。该错误是一些 flash 与 activeX 不兼容。

我遇到了同样的问题,我的应用 运行 几个月没有问题,在安装提到的 Microsoft 更新后的那些日子里:

Windows Flash 更新 (KB3132372)

打开带有嵌入式浏览器的对话框时,我的应用程序崩溃了。奇怪的是,呈现的网页没有flash元素,卸载此更新(KB3132372)后一切正常。

也许有帮助。

我开发的一个使用 webBrowser 控件的应用程序也有几乎相同的问题。在此应用程序中,我启用了浏览器仿真,让用户 select 浏览器用于可视化网站。
浏览器仿真代码设置注册表项:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

使用包含应用程序名称的键和 select 浏览器要模拟的值。 (IE8 为 8000d,IE9 为 9000,Edge 为 11001)。

几天前,应用程序开始崩溃,没有对软件进行任何修改。经过一天半的调查,我发现了以下规则:

  • 当密钥被 selected 时,浏览器和我的应用程序一起崩溃。
  • 当密钥未被 selected 时,应用程序不会崩溃,但它会模拟旧版本的 IE。

我仍在调查这个主题,如果我发现更多内容,我会在此处发布。

无论如何,删除 KB3132372 问题就解决了,但是这个 KB 会在 Win10 上自动加载,如果用户不知道这个问题,它可能会造成破坏。

关于 KB3132372 禁用此更新的进一步上传的重要建议:它在许多基于 webBrowser 控件的应用程序中引起了很多问题。您可以建议您的客户删除它并使用 Windows 更新 Show/Hide 实用程序来隐藏更新(请参阅 https://support.microsoft.com/en-au/kb/3073930),否则它会在每次自动上传时再次上传。

我在 W8/W10 上的 webbrowser 控件导航到包含 ActiveX(Flash) 的页面时遇到同样的问题。

目前唯一的解决方案是删除 KB3132372 windows 更新。它可以通过cmd命令来制作:

wusa.exe /uninstall /kb:3132372 /norestart /quiet

很遗憾Windows 8/10 以后会尝试重新安装。由于这个原因,也可以隐藏此更新,如图所示 here

关于我,仅当网络浏览器组件通过 youtube iframe 加载 youtube 视频时才会出现问题 api。这让我发疯,因为几天前一切都很完美。 确认解决方案正在删除 KB3132372 使用 wusa.exe /uninstall /kb:3132372 /norestart /quiet

非常感谢。

正如 StefanBelo 的回答,问题是 Windows Flash 更新 (KB3132372)。

现在问题已在KB3133431中解决。 只需 运行 你的 Windows 更新,问题就应该得到解决(对我来说是这样)。