dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.44k stars 988 forks source link

Some .NET 7 WinForms controls still reference .NET Framework 4.8 #9767

Open sergey-m-pega opened 1 year ago

sergey-m-pega commented 1 year ago

.NET version

.NET 7

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

.NET 4.8.1

Issue description

Our Windows based app offers Toolbox like functionality allowing user to drop controls onto WinForms design surface. In the process of doing that, .NET ToolboxItem looks at it's declared ToolboxItemAttribute. That is the attribute that still points at .NET Framework 4.8 as evident by examining components with tool like Reflector. Affected components are: Label, LinkedLabel, Checkbox and RadioButton. Here's a sample of decompiled class:

[ToolboxItem($"System.Windows.Forms.Design.AutoSizeToolboxItem,{AssemblyRef.SystemDesign}")]
public partial class Label : Control, IAutomationLiveRegion

AssemblyRef is the part that points at .NET Framework 4.8. Worse yet, there is no equivalent type definition in .NET 7 afaict.

Steps to reproduce

It's rather difficult to setup steps to reproduce considering that WinForms designer stack is not something that could be easily isolated. Obviously it somehow still works with Visual Studio own WinForms .NET 7 designer, as VS is a black box. I'm not sure where the disconnect is. What I'm looking for is to see if doc update of some sort is needed, or if a workaround is available.

sergey-m-pega commented 11 months ago

I am sadly running into that same issue now on .NET 8. Our application utilizes designer stack, providing for design surface and an ability to D&D controls on it. That's where we ran into an issue of missing AutoSizeToolboxItem type on some controls, Label for instance. Does anyone have any suggestions as to how to work around it? I'd appreciate it.