C
C#2d ago
h3x4by73

Visual Studio doesn't recognize windows form as form anymore (no designer view)

Since one of the newer updates, visual studio now checks for the target .Net version and according to documentation only shows the forms designer for projects targeting .Net 8 or higher. If I create an entirely new winforms project with target version .Net 8 or migrate an existing < 8.0 project to 8 (or even 9), the designer won't open and also vs doesn't recognize the form as such anymore (see attached image). Did anyone else have this issue before and found a solution to get the designer back?
No description
47 Replies
MODiX
MODiX2d ago
* close VS * remove the hidden folder .vs * remove all bin and obj folder next to each csproj (DO NOT TOUCH THE .git FOLDER OR WHAT'S INSIDE) * restart vs
jcotton42
jcotton422d ago
Share your csproj @h3x4by73
h3x4by73
h3x4by73OP2d ago
Here's the csproj content: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net9.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWindowsForms>true</UseWindowsForms> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> </Project>
leowest
leowest2d ago
that usually happen when u add classes on top of the main form class so u lose the ability to open the designer can u post the content of form1.cs preferable use the site below to $paste
MODiX
MODiX2d ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
h3x4by73
h3x4by73OP2d ago
as I wrote in the starting post - there is really nothing special within that form, it even happens when I create a blank winforms project without adding any custom code at all. But here's the content: https://paste.mod.gg/izzfbdknxhrd/0
BlazeBin - izzfbdknxhrd
A tool for sharing your source code with the world!
leowest
leowest2d ago
very weird indeed, have u tried repairing your visual studio install by going to the installer
leowest
leowest2d ago
No description
h3x4by73
h3x4by73OP2d ago
I did a full reinstall, nothing changed
leowest
leowest2d ago
and can u show the workloads u have selected in the installer
h3x4by73
h3x4by73OP2d ago
interestingly if I create an empty project targeting .net 9 it works
leowest
leowest2d ago
sounds like u might have something in conflict causing the issue tbh
h3x4by73
h3x4by73OP2d ago
but only if I select .net 9 as target when creating the project. If I change it later on it doesn't work. I also compared all the files (sln, csproj, csproj.user), even if they're exactly similar for the .net 9 project it works right away, for the one started with 8 it doesn't
leowest
leowest2d ago
anyway can u show me what workloads u have selected in installer
h3x4by73
h3x4by73OP2d ago
those are my workloads
No description
leowest
leowest2d ago
and also run a dotnet --info and are u running a preview or stable version or visual studio
h3x4by73
h3x4by73OP2d ago
BlazeBin - abazlsjmbfzm
A tool for sharing your source code with the world!
h3x4by73
h3x4by73OP2d ago
according to the installer I have version 17.13.6 installed. I did not manually select any preview version
leowest
leowest2d ago
this looks fine mmm so to review the case if u create winforms with .net9 it all works if u modify the csproj to .net 8 it all breaks
h3x4by73
h3x4by73OP2d ago
it's the other way round didn't try to start with .net 9 and switch to 8 then yet
leowest
leowest2d ago
you said above if u start with 9 it works so that got me confused
h3x4by73
h3x4by73OP2d ago
ok let me write it down again: starting with net 9 works starting with net 8 doesn't work starting with net 7, then upgrading to 8 didn't work either. upgrading from 8 to 9 still didn't work
leowest
leowest2d ago
ok so everything works except 8?
h3x4by73
h3x4by73OP2d ago
i just tried starting with .net 9 and switched to .net 8, for some reason this way it works
leowest
leowest2d ago
yeah that is very weird indeed because the only change in that case is in the csproj the templates are the same I imagine ok what if u create a project on .net 8 then right click and build does it build successfully despite not opening the designer
h3x4by73
h3x4by73OP2d ago
well now things starting to get really strange. For some reason creating a .net 8 worked this time. What the hell
leowest
leowest2d ago
:bigthonk: that makes me think you're having some memory issue or some hardware related issue causing this weirdness Check Event Viewer for anything suspicious and perhaps run a memory check(MemTest86) to ensure its good
h3x4by73
h3x4by73OP2d ago
it might be that it changed after reinstalling and i only tried the other way after reinstalling
leowest
leowest2d ago
I mean sure but none of the cases u listed would cause the designer to break
h3x4by73
h3x4by73OP2d ago
the main problem why this occured to me was that I have a .net7 project which then gave me the warning from vs that since support is dropped for .net 7 now also the designer won't show up anymore. So I tried upgrading and since then the designer broke for that project and I kept getting strange behavior from the designer and after that even the templates didn't work anymore for me
leowest
leowest2d ago
mmm I dont think it would break just because its out of support, but still the only thing u would need to change is the version in the csproj assuming its a clean winforms project ofc if u have an actual project there might be libraries and whatnot u would need to update along
h3x4by73
h3x4by73OP2d ago
creating a new .net 7 winforms project gives me this warning in the designer: When i first had this warning and closed the designer, all my forms proceeded to not be loaded in the designer anymore
No description
h3x4by73
h3x4by73OP2d ago
it says in future versions the designer will not load anymore for .net 7 projects
leowest
leowest2d ago
I see, indeed. but it would still be a matter of updating the csproj to a newer version and then just reloading the project
h3x4by73
h3x4by73OP2d ago
well I tried exactly this but it simply doesn't recognize the forms as forms. It groups them together correctly but that's it the icon remains the icon of a normal c# file and the context menu gives no possibility to open the designer
leowest
leowest2d ago
you change from 7 to 8 in the csproj, save, close the solution and then open it again?
h3x4by73
h3x4by73OP2d ago
i changed from 7 directly to 9 but apart from that, yes
leowest
leowest2d ago
what if u delete the bin and obj folders before u open it again does it go back to working I did a quick test here but im on preview version of visual studio, changing it to 7 completely breaks the designer from opening, it doent change the icons or anything and I have to right click project, clean, change to 9, close vs and open it again but it all worked fine after that
h3x4by73
h3x4by73OP2d ago
i tried deleting obj and bin and clearning but still same result anyway I need to get some sleep. Thank you very much for your help, I'll give it another go tomorrow
Petris
Petris2d ago
it's a VS bug it does it from time to time tf is the bot doing
leowest
leowest2d ago
bot loves u @Patrick bot gone crazy, any message some one sends it does this triple message(looks like its fixed now but it was doing it in any channel)
leowest
leowest2d ago
No description
leowest
leowest2d ago
No description
Petris
Petris2d ago
anyway deleting .vs sometimes helps with this
leowest
leowest2d ago
@h3x4by73 give that a try before u go if u can
h3x4by73
h3x4by73OP2d ago
tried this already a few times. I can try again after the clean now, sec nope, still unchanged. Thanks anyway
Lex Li
Lex Lithis hour
The out-of-process WinForms designer remains a preview if you read relevant documentation again. So, please use Help | Send Feedback | Report a Problem... to report such issues.

Did you find this page helpful?