在复杂的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.”