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

geoffhop

New member
Joined
Aug 17, 2021
Messages
4
Programming Experience
10+
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.

Anybody else having the same or similar issues?


Thanks in advance
Geoff
 

Attachments

  • ProjectTest.zip
    143.4 KB · Views: 26
I just tried creating a custom control in a .NET Framework 4.8 project and it worked fine, then tried in a .NET 5.0 project and the designer showed an error. It seems to be a bug in the .NET 5 WinForms designer. While the majority of what people usually use is there and working, there are still a number of things that are broken or missing in .NET 5 WinForms development. It is for this reason that I tend to recommend to WinForms developers to stick with .NET Framework for now. All you can probably do for now is report the bug to Microsoft and wait for them to address it.
 
I just tried creating a custom control in a .NET Framework 4.8 project and it worked fine, then tried in a .NET 5.0 project and the designer showed an error. It seems to be a bug in the .NET 5 WinForms designer. While the majority of what people usually use is there and working, there are still a number of things that are broken or missing in .NET 5 WinForms development. It is for this reason that I tend to recommend to WinForms developers to stick with .NET Framework for now. All you can probably do for now is report the bug to Microsoft and wait for them to address it.
Hi thanks for the reply. Yeah I am multitargeting 4.6.2 and 5 and .NET Framework has no issues whilst .NET 5 does
It was just that Microsoft have been speaking about incorporating support for visual inheritence since at least VS 2019 16.6 approx 18 months ago and we are now at 16.11 and we still don't have good support for it. I just pray it will get done as we have a large mature project that makes heavy use of visual inheritence.
Thanks again
Geoff
 
One point to note is that, as far as I can see, the code for a .NET 5 custom control and a .NET Framework custom control are identical. That should mean that you could design the control in a .NET Framework project and then either add the control as an existing item to the .NET 5 project or copy and paste the code into an existing control manually. That might be your best option for a workaround right now.
 
One point to note is that, as far as I can see, the code for a .NET 5 custom control and a .NET Framework custom control are identical. That should mean that you could design the control in a .NET Framework project and then either add the control as an existing item to the .NET 5 project or copy and paste the code into an existing control manually. That might be your best option for a workaround right now.
Hi there, thanks for the reply, yeah that is exactly what I am now doing, in fact my SDK style csproj file multitargets .NET 4.6.2 and .NET 5, as 4.6.2 is listed first it uses the Frameworks designer which alllows me to. I am just a little worried about what this will look like when .NET Framework is off of the scene!
Thanks again
Geoff
 
I am just a little worried about what this will look like when .NET Framework is off of the scene!
4.6.2 has probably got at least two years of support left and 4.8 will have several years after that. We'll be well into .NET 6 and may even have see .NET 7 by then.
 

Latest posts

Back
Top Bottom