dotnet / winforms

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

Issue with Visual Studio 2019 Designer when used in combination with Visual Inheritance and .NET 5 Windows #5444

Closed geoffhop closed 2 years ago

geoffhop commented 3 years ago

Hi there I am confronting an issue with the Visual Studio 2019 Designer when used in combination with visual inheritance and .NET 5 Windows I have a net5.0-windows SDK style WinForms project using Visual Studio 2019 this issue is occuring in all versions I have tried across different PC's, v16.11.1, v16.10.4 and v16.9.5 I also have the .NET 5 SDK v5.0.400 installed which is part of .NET 5 v5.0.9 (yep confusing I know).

Basically any control that does not inherit directly from UserControl cannot be viewed in the Visual Studio designer including a newly created "Custom Control" created straight from the Visual Studio template selection under the WIndow Forms group.

This is a designer error only with no issues in compilation, viewing code, or at runtime.

I have attached an example solution 1/ You should rebuild the solution when you open it as often the designer will not even open controls that are not derived from UserControl if you have not rebuilt the solution. It just seems to ignore the fact you choose "View Designer".

2/ In solution explorer you should in turn right click on each control and choose "View Designer". Both the CustomControl1 and LabelControl have errors in the designer whilst UserControl1 doest not have errors.

You may get a slightly different error depending on the version of Visual Studio 2019 but I have added 2 png files to the attached zip file that show the errors I was receiving.

Is this a known issue? And if so is there an intention to get this working without errors as we have a large solution that makes heavy use of visual inheritance from base class controls and forms.

Thanks in advance Geoff

ProjectTest.zip

Marie-Shi commented 3 years ago

Hi geoffhop, yes, there is a known issue about cannot open the form designer for Custom Control, and we are working on it.

Marie-Shi commented 3 years ago

There is a known Designer issue.

geoffhop commented 3 years ago

Hi thereThanks for the reply but the link gives a 404 errorRegardsGeoff On Wednesday, August 18, 2021, 11:10:52 AM GMT+8, v-zheshi @.***> wrote:

There is a known Designer issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Marie-Shi commented 3 years ago

@geoffhop This is a private link in designer repo. We'll update this issue once we make any progress.

geoffhop commented 2 years ago

Hi there Does anybody have an update on this as this is still an issue in both VS 2019 and VS 2022

Regards Geoff

ghost commented 2 years ago

I’ve just tried your sample in vs 2022 and get no problems. I’m now working in VS2022 and .net 6 and have only one problem with the designer, when it causes a catastrophic error seemingly at random. Closing any open designer windows usually fixes it.

From: geoffhop @.> Sent: 08 February 2022 08:45 To: dotnet/winforms @.> Cc: Richard Fenton @.>; Manual @.> Subject: Re: [dotnet/winforms] Issue with Visual Studio 2019 Designer when used in combination with Visual Inheritance and .NET 5 Windows (#5444)

Hi there Does anybody have an update on this as this is still an issue in both VS 2019 and VS 2022

geoffhop commented 2 years ago

Hi MHDeveloper30 Thanks for the reply. I just tried it again and both CustomControl1 and LabelControl fail to load in the designer using VS Pro 2022 (64 bit) v17.0.6 with both displaying the same error which I have attached. Maybe it is an issue based on environment\configuration. Do you have any particular additional SDK's installed? 2022-02-09.pdf

Regards geoffhop

geoffhop commented 2 years ago

Hi yet again Further to this I have just tested this on a brand new Windows Server 2019 VM box with no other installs of Visual Studio other than VS 2022 Community 64 bit v17.0.6 with only the .NET desktop developement workload installed and I still get the same errors when opening both the CustomControl1 and LabelControl controls in the designer.

Regards geoffhop

ghost commented 2 years ago

Apologies, I’ve just reread your post and followed your steps to recreate more carefully ie right click and select ViewDesigner and I do get an error – object not found. I was just double-clicking and getting the code behind file. I’m wondering why you want to design the inherited control? Is it a possible workaround to inherit from UserControl (which does display the designer) and then add the control to the user control?

From: geoffhop @.> Sent: 09 February 2022 08:34 To: dotnet/winforms @.> Cc: Richard Fenton @.>; Manual @.> Subject: Re: [dotnet/winforms] Issue with Visual Studio 2019 Designer when used in combination with Visual Inheritance and .NET 5 Windows (#5444)

Hi yet again Further to this I have just tested this on a brand new Windows Server 2019 VM box with no other installs of Visual Studio other than VS 2022 Community 64 bit v17.0.6 with only the .NET desktop developement workload installed and I still get the same errors when opening both the CustomControl1 and LabelControl controls in the designer.

geoffhop commented 2 years ago

Hi MHDeveloper30 Thanks for confirming, plenty of other developers out there are also seeing this issue and it's a know bug that has not been fixed. I have dozens of inherited controls that I need to design that inherit from Control rather than UserControl, Microsoft themselves do it with System.Windows.Forms.Label. Infragistics are another 3rd party control designer who do the same. It's not realistic for me to go back to redesign all these controls particularly when it's a know issue that is still to be addressed.

Thanks again

RussKie commented 2 years ago

The OOP designer still lacks the support for components design, the issue is tracked under https://github.com/dotnet/winforms-designer/issues/4126 (Microsoft internal). For a possible workaround please refer to https://github.com/dotnet/winforms/blob/main/docs/designer/net-inproc-designer.md.

If you have any questions please use https://github.com/dotnet/winforms/discussions.

Thank you.