-1

I will try to keep this short.

Recently, in Visual Studio 2022, I have moved my C# app from .NET 7.0 (Core) to .NET Framework 4.8, mostly because it promised better functionality for Excel interop management.

After some necessary tweaking, I have the app running just fine (all connections and event settings), but the visual form designer for Form1 doesn't match the Form1.Designer.cs file at all. The visual editor is literally blank, without the icon that displays when i run the ap and altogether in its default state.

I have tried a couple solutions from the community here, but nothing has worked so far.

At least for now, I do not have any code to show, since I am doing this sort of thing for the first time and have no clue as to what could cause this to happen.

Any ideas?

O_W
  • 37
  • 4
  • May be it's due to changes into designer codegeneration https://devblogs.microsoft.com/dotnet/winforms-codegen-update/? – Serg Apr 28 '23 at 17:21
  • Does the form display when you run the application? Or is only the display in the designer broken? – PMF Apr 29 '23 at 04:50
  • @PMF The form displays just fine, everything is where it should be and calls my functions properly. I just can't see it in the designer. – O_W Apr 29 '23 at 13:27
  • Ok, then maybe the link above helps. I have only done conversions the other way, but I haven't seen any changes that would cause the designer to behave that way. – PMF Apr 29 '23 at 13:31
  • One thing to check: Make sure your form has a default constructor and that it calls the `InitializeComponent()` function. – PMF Apr 29 '23 at 13:32

1 Answers1

0

Solved it!

First, I had tried checking for common mistakes in code structure, as was suggested here in the comments. But then I'd gotten a little curious about how the entire working solution should look in the solution explorer tree view, so I looked up some examples.

It turns out, the Form1.cs and Form1.Designer.cs I had imported as entire files didn't couple correctly, meaning that the designer didn't get put in the branch under Form1 in the tree. It also had a different icon and all-in-all did not exactly match the newly added forms designers.

To cut to the chase, the thing that solved this was just adding Form1 as an entirely new form and pasting all the necessary code to it and its designer.

I also had to reassign the events of my controls to the right functions, but this wasn't much of an issue for a single form. After a couple more tweaks with icons and other media resources, everything works as intended.

Here is how it all should look, in case that anyone encounters the same dumb issue in the future:

Correct solution view

If it looks any other way, just move the code to a fresh new form and scrap the old one.

Thanks for the support!

O_W
  • 37
  • 4