【发布时间】:2015-12-31 03:28:06
【问题描述】:
以下简短代码示例演示了某些页面的 WebBrowser 崩溃。该问题在 2015 年 12 月 26 日至 27 日全新安装 Windows 10 和 Visual Studio Community 2015 后开始出现。之前安装 Windows 10 和 Visual Studio Community 2015 时未出现此问题。同一程序已在另一台计算机上进行了测试相同的软件和操作系统以及相同的问题 发生。
点击“下载 2”成功从 Google 下载页面。
单击“下载 1”开始从 Bloomberg 下载,在大部分页面可见后,会打开一条弹出消息,其中显示“WindowsFormsApplication1.exe 已触发断点”。执行在“Application.Run(new Form1())”行停止。有时错误消息在页面滚动之前不会显示。在 IE11 上下载相同的 URL 没有问题,开发者工具/兼容性表明没有问题。将注册表中的 Webbrowser 仿真级别设置为 11001 没有任何区别。 WebBrowser1.ScriptErrorsSuppressed 没有区别。
如果单击“继续”,则会打开另一条消息,其中显示“WindowsFormsApplication1.exe 中 0x12C731C2 (Flash.ocx) 处的未处理异常:0xC0000602:发生快速失败异常。将不会调用异常处理程序 并且该进程将立即终止。”
如果选择“继续”,则会打开另一条消息,其中显示“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;
}
}
}
}
【问题讨论】:
标签: c# webbrowser-control