C
C#7mo 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
49 Replies
MODiX
MODiX7mo 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
jcotton427mo ago
Share your csproj @h3x4by73
h3x4by73
h3x4by73OP7mo 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
leowest7mo 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
MODiX7mo 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
h3x4by73OP7mo 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
leowest7mo ago
very weird indeed, have u tried repairing your visual studio install by going to the installer
leowest
leowest7mo ago
No description
h3x4by73
h3x4by73OP7mo ago
I did a full reinstall, nothing changed
leowest
leowest7mo ago
and can u show the workloads u have selected in the installer
h3x4by73
h3x4by73OP7mo ago
interestingly if I create an empty project targeting .net 9 it works
leowest
leowest7mo ago
sounds like u might have something in conflict causing the issue tbh
h3x4by73
h3x4by73OP7mo 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
leowest7mo ago
anyway can u show me what workloads u have selected in installer
h3x4by73
h3x4by73OP7mo ago
those are my workloads
No description
leowest
leowest7mo ago
and also run a dotnet --info and are u running a preview or stable version or visual studio
h3x4by73
h3x4by73OP7mo ago
BlazeBin - abazlsjmbfzm
A tool for sharing your source code with the world!
h3x4by73
h3x4by73OP7mo ago
according to the installer I have version 17.13.6 installed. I did not manually select any preview version
leowest
leowest7mo 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
h3x4by73OP7mo ago
it's the other way round didn't try to start with .net 9 and switch to 8 then yet
leowest
leowest7mo ago
you said above if u start with 9 it works so that got me confused
h3x4by73
h3x4by73OP7mo 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
leowest7mo ago
ok so everything works except 8?
h3x4by73
h3x4by73OP7mo ago
i just tried starting with .net 9 and switched to .net 8, for some reason this way it works
leowest
leowest7mo 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
h3x4by73OP7mo ago
well now things starting to get really strange. For some reason creating a .net 8 worked this time. What the hell
leowest
leowest7mo 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
h3x4by73OP7mo ago
it might be that it changed after reinstalling and i only tried the other way after reinstalling
leowest
leowest7mo ago
I mean sure but none of the cases u listed would cause the designer to break
h3x4by73
h3x4by73OP7mo 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
leowest7mo 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
h3x4by73OP7mo 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
h3x4by73OP7mo ago
it says in future versions the designer will not load anymore for .net 7 projects
leowest
leowest7mo 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
h3x4by73OP7mo 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
leowest7mo ago
you change from 7 to 8 in the csproj, save, close the solution and then open it again?
h3x4by73
h3x4by73OP7mo ago
i changed from 7 directly to 9 but apart from that, yes
leowest
leowest7mo 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
h3x4by73OP7mo 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
Petris7mo ago
it's a VS bug it does it from time to time tf is the bot doing
leowest
leowest7mo 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
leowest7mo ago
No description
leowest
leowest7mo ago
No description
Petris
Petris7mo ago
anyway deleting .vs sometimes helps with this
leowest
leowest7mo ago
@h3x4by73 give that a try before u go if u can
h3x4by73
h3x4by73OP7mo ago
tried this already a few times. I can try again after the clean now, sec nope, still unchanged. Thanks anyway
Lex Li
Lex Li7mo ago
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.
h3x4by73
h3x4by73OP7mo ago
I solved it: I copied the whole project to another path (short, without any spaces or special signs) and now the forms are recognized correctly again. I found some tickets regarding similar issues where this was the problem in earlier vs versions. Seems like it now happens again. In the earlier version it was due to paths with signs that are exchanged on the keyboard compared to an english one (I'm using a german keyboard/system and vs installation)
MODiX
MODiX7mo ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?