Microsoft.NETCore.App.Ref v5.0.0
Microsoft.WindowsDesktop.App.Ref v5.0.0
- Have you experienced this same bug with .NET Framework?:
No.
Problem description:
When I build this control in .NET Framework and then drag it onto a .NET Framework Windows Form design surface, OnCreateHandle is called and the MessageBox is shown. However, when I build this control in .NET 5.0 (net5.0-windows) with UseWindowsForms true and then drag it onto a .NET 5.0 Windows Forms design surface, OnCreateHandle is not called and the MessageBox does not show.
Expected behavior:
I would expect OnCreateHandle to be called in .NET 5.0 in the same way as it is called in .NET Framework 4.6
Minimal repro:
[Designer(typeof(TestDesigner))]
public class NETFrameworkControl : Control
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.FillRectangle(Brushes.Red, e.ClipRectangle);
}
public class TestDesigner : System.Windows.Forms.Design.ControlDesigner
{
protected override void OnCreateHandle()
{
base.OnCreateHandle();
MessageBox.Show("OnCreateHandle");
}
}
}
Microsoft.NETCore.App.Ref v5.0.0
Microsoft.WindowsDesktop.App.Ref v5.0.0
No.
Problem description:
When I build this control in .NET Framework and then drag it onto a .NET Framework Windows Form design surface, OnCreateHandle is called and the MessageBox is shown. However, when I build this control in .NET 5.0 (net5.0-windows) with UseWindowsForms true and then drag it onto a .NET 5.0 Windows Forms design surface, OnCreateHandle is not called and the MessageBox does not show.
Expected behavior:
I would expect OnCreateHandle to be called in .NET 5.0 in the same way as it is called in .NET Framework 4.6
Minimal repro: