4

MyForm is inherited from Form. I am able to inherit MyForm in VS2022 application. However, if MyForm is inside a library and my VS2022 application tries to create a form that is inherited from MyForm then I got an error:

"The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: --- The base class '' could not be loaded. Ensure the assembly has been referenced and that all projects have been built. "

I would think this is a bug in VS2022 latest version. I have no issue in Visual Studio 2019/2010 Any work around for this issue would be great.

Thanks

Julio Nobre
  • 4,196
  • 3
  • 46
  • 49
  • I get this error even if I add the inherited form via Visual Studio itself: Project -> Add -> New Item -> Inherited Form (Windows Forms), and point it to my base form when prompted. It should be embarrassing to Microsoft that this is so broken. There is nothing special about my base form (no overloaded constructor or anything manually changed). – Dan Sorak Oct 28 '22 at 14:18

1 Answers1

4

It seems this a Visual Studio 2022 bug that affects only inherited forms whenever their base classes are stored on x86 dll assemblies.

As of today, using Microsoft Visual Studio Professional 2022 (64-bit) - Version 17.3.3, C# Form Designer is unable to design/load previous forms.

Fortunately there are several workarounds.

Workaround 1 (VS2022)

On Configuration Manager, locate the project that contains your form base class (the form class which your offending form as inherited from) and change Platform from Any CPU to x86, save and rebuild it. Your target form should load ok.

enter image description here

Workaround 2 (VS2022)

One guy, Frank Wenzl, figured out that changing Output type from Class Library (.dll) to Windows Application (.exe) on the project that contains the form base class and rebuilding it, allow Windows Form Designer to load inherited forms normally.

enter image description here

Workaround 3 (VS2019 or prior versions)

Using Microsoft Visual Studio Professional 2019 (32 bit, i guess) - Version 16.9.4, C# Form Designer allowed me to proceed my work.

For further info on this issue, check:

Julio Nobre
  • 4,196
  • 3
  • 46
  • 49