Windows 10创建者更新破坏Winforms应用程序 / BSOD



在复杂的Winforms应用程序中有许多层时,Windows 10创建者崩溃。可以轻松地使用以下代码复制。悬停或单击> = 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上的另一个问题有关(相同?(。请参阅此处。

update

Microsoft提供了一个修复程序:https://support.microsoft.com/en-us/help/4022716/windows-10-10-update-kb4022716

这是其描述:

" windows表单(Winforms(的地址问题(错误0x7f(,该符号(Winforms(导致系统升级到创建者更新后崩溃。"

似乎是相同的,或者在Win10 build 1803中再次出现了一个类似的问题。以下代码在使用标签/窗口上移动鼠标时迅速触发A BSOD。

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace FormWithButton
{
    public class Form1 : Form
    {
        public Form1()
        {
            Control p = this;
            for (int i = 1; i < 48; i++) {
                var p2 = new Panel();
                p.Controls.Add(p2);
                p = p2;
            }
            var b = new Label();
            b.Text = "Hello";
            p.Controls.Add(b);
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }
    }
}

相关内容

最新更新