Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add C# class in visual studio 2019 anymore - Won't link to main file

So I am new to C# and Vs Studio. I was playing around learning it by adding new classes and testing what I could do. However, today it seems like no matter what I do, when I create a new class it won't link to the main file.

For example, I will go to the toolbar up top and navigate to Project -> Add New Item -> Visual C# Class

I notice I no longer get the option to name the file in this window like I use to

Window

I have working classes currently from the last time I did this and tried to create a new file in the project and just copy/paste all the code while changing the name of the class, still didn't work.

Not sure what is going on anymore as I've followed YouTube tutorials click for click but it still doesn't work.

FIle Scructure

Below are the stats of my VS studio which I havent changed since the last time I've used it and the last time I used it, creating a c# class worked without these problems.

Microsoft Visual Studio Community 2019
Version 16.9.4
VisualStudio.16.Release/16.9.4+31205.134
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ASP.NET and Web Tools 2019   16.9.693.2781
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.9.693.2781
Azure App Service Tools v3.0.0

C# Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   5.9.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

TypeScript Tools   16.0.30201.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
like image 208
matt_3773 Avatar asked Oct 23 '25 05:10

matt_3773


1 Answers

Your solution explorer is in "Folder View" - it behaves differently in that view. To switch back to the regular view, click the "Switch between solutions and views" icon in Solution Explorer (circled), and double click you solution file (.sln):

enter image description here

enter image description here

After you are back in your solution view, you should be able to right click and add an item to add a class file again, and choose its name before creating it.

like image 191
Timothy G. Avatar answered Oct 25 '25 20:10

Timothy G.