当复杂的 WinForms 应用中有多个层时,Windows 10 Creators 会崩溃。这可以很容易地用下面的代码重现。当悬停或单击 >= 40 层顶部的 UI 时,系统会崩溃并出现 BSOD。它应该会遇到异常。
有人知道避免完全崩溃的调整吗?
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PanelLayers
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int maxCount = 45;
int count = 0;
this.CreateLayers(this, maxCount, ref count);
}
private void CreateLayers(Control BaseControl, int MaxCount, ref int Count)
{
if(Count == MaxCount)
{
Button btn = new Button();
btn.Text = "Click me";
btn.Location = new Point(8, 8);
btn.Click += btn_Click;
BaseControl.Controls.Add(btn);
}
else
{
Count++;
Panel pnl = new Panel();
pnl.Dock = DockStyle.Fill;
try
{
BaseControl.Controls.Add(pnl);
this.CreateLayers(pnl, MaxCount, ref Count);
}
catch(Exception ex)
{
MessageBox.Show(String.Format("Exception hit at count {0}{1}{2}{1}{3}", Count, Environment.NewLine, ex.Message, ex.StackTrace));
}
}
}
void btn_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello Creators Update!");
this.Close();
}
}
}
最佳答案
它看起来可能与 Windows 8/Windows Server 2012 上发现的另一个问题(相同?)有关。参见 here .
更新
Microsoft 已提供修复:https://support.microsoft.com/en-us/help/4022716/windows-10-update-kb4022716
这是它的描述:
"Addressed issue (Error 0x7F) with Windows Forms (WinForms) that causes the system to crash after upgrading to the Creators Update."
关于Windows 10 Creators Updates 破坏了 WinForms 应用程序/蓝屏死机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43583651/