I have a simple Control which reproduces the issue:
[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");
}
}
}
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.
Does anybody know if there is a workaround to this problem? Thank you!