问题描述
以下简短代码示例演示了某些页面的 WebBrowser 崩溃.该问题是在 2015 年 12 月 26 日至 27 日全新安装 Windows 10 和 Visual Studio Community 2015 后出现的.之前安装的 Windows 10 和 Visual Studio Community 2015 未出现此问题.同一程序已在另一台计算机上测试过同样的软件和操作系统,同样的问题发生.
The following short code example demonstrates WebBrowser crashing for some pages. The problem started after a fresh installation of Windows 10 and Visual Studio Community 2015 on 26-27 December 2015. The problem did not occur with the previous installation of Windows 10 and Visual Studio Community 2015. The same program has been tested on another computer with the same software and operating system and the same problemoccurs.
点击下载 2"成功从 Google 下载页面.
Clicking 'Download 2' successfully downloads the page from Google.
单击下载 1"开始从 Bloomberg 下载,在大部分页面可见后,会打开一条弹出消息,其中显示WindowsFormsApplication1.exe 已触发断点".执行在Application.Run(new Form1())"行停止.有时,直到滚动页面才会显示错误消息.在 IE11 上下载相同的 URL 没有问题,开发人员工具/兼容性表明没有问题.将注册表中的 Webbrowser 仿真级别设置为 11001 没有任何区别.WebBrowser1.ScriptErrorsSuppressed 没有区别.
Clicking 'Download 1' starts downloading from Bloomberg and after most of the page is visible a popup message opens with "WindowsFormsApplication1.exe has triggered a breakpoint." with execution stopped at line "Application.Run(new Form1())". Sometimes the error message does not show until the page is scrolled. The same URL downloads on IE11 without problems and Developer Tools / compatibility indicates no problems. Setting the Webbrowser emulation level in registry to 11001 makes no difference. WebBrowser1.ScriptErrorsSuppressed makes no difference.
如果单击继续",则会打开另一条消息WindowsFormsApplication1.exe 中 0x12C731C2 (Flash.ocx) 处的未处理异常:0xC0000602:发生快速失败异常.将不会调用异常处理程序并且该过程将立即终止."
If 'continue' is clicked another message opens with "Unhandled exception at 0x12C731C2 (Flash.ocx) in WindowsFormsApplication1.exe: 0xC0000602: A fail fast exception occurred. Exception handlers will not be invokedand the process will be terminated immediately."
如果选择继续",则会打开另一条消息WindowsFormsApplication1.exe 中的 0x00000000 处抛出异常:0xC0000005:访问冲突执行位置 0x00000000.如果有此异常的处理程序,该计划可以安全地继续."
If 'continue' is selected another message opens with "Exception thrown at 0x00000000 in WindowsFormsApplication1.exe: 0xC0000005: Access violation executing location 0x00000000. If there is a handler for this exception,the program may be safely continued."
有什么可以解决问题的吗?
Is there something that can solve the problem?
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,但几个小时后它停止工作.
I got the same problem with an application on Windows 10, it works fine on Windows XP / Vista / 7 / 8 / 8.1 and even in fresh installs of Windows 10, but after a few hours it stops working.
该应用程序是在 Visual Studio 2010 上开发的,并切换到 Visual Studio 2013 Ultimate 认为它可能是 Edge/ActiveX 不兼容问题,但没有:(
The application was developed on Visual Studio 2010 and switched up to Visual Studio 2013 Ultimate thinking that it could be an Edge / ActiveX incompatibilityproblem but no :(
更新
此问题已在 Microsoft 的此更新中得到解决.错误是 Flash 与 activeX 不兼容.
The issue is fixed in this update from Microsoft. The bug was some flash incompatibility with activeX.
这篇关于WebBrowser 控件在 Windows 10 上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!