Borys Shobat
Borys Shobat

Reputation: 255

Visual studio solution explorer not showing form cs file

enter image description here

Cant find user code file of Windows form in solution explorer, now I must right click on form class and choose <>View Code. But there always been cs file at the bottom of class. enter image description here

Upvotes: 9

Views: 14952

Answers (5)

stevenparker3223
stevenparker3223

Reputation: 1

I am using VS2019 and the same problem was for me. But I solved this issue. I used Visual Assist for VS2019 and after expiration I uninstalled it. After that I got this issue. So I re-installed it again and licensed it. Then, it works now.

Upvotes: 0

Corodeanu Lucian
Corodeanu Lucian

Reputation: 40

I encountered the same issue, not displaying my Form. What you should do is:

  • /project_directory/project_name.csproj edit this file and make sure your_form_name.cs is like this:

Notice: first delete all records from this file with existing your_form_name.cs and add the following:

`<Compile Include="your_form_name.cs">
   <SubType>Form</SubType>
</Compile>
<Compile Include="your_form_name.Designer.cs">
   <DependentUpon>your_form_name.cs</DependentUpon>
</Compile>
   <EmbeddedResource Include="your_form_name.resx">
   <DependentUpon>your_form_name.cs</DependentUpon>
</EmbeddedResource>`

Open solution again and Form will be shown in your project once again.

Upvotes: 2

user3122306
user3122306

Reputation: 245

Same error here.

Visual Studio Professional 2015. Version installed: 14.0.25431.01 Update 3 (with the KB3165756)

This wrong behaviour started after installing Azure SDK 2.9.6, that installs .NET Core stuff & .NET Core templates into Visual Studio 2015 (actually installed .NET Core Tools (Preview 2) 14.1.21111.0)

If you add Class Library (.NET Core) or Console Application (.NET Core) to your C# solution, the forms.cs become visible again in solution explorer

Before adding Class Library (.NET Core):

enter image description here

After Class Library (.NET Core) added to Solution:

enter image description here

There is something wrong with .NET Core stuff. Hopefully it fixes on future patches.

Upvotes: 3

Borys Shobat
Borys Shobat

Reputation: 255

Maybe its not best solution but after complete removing and installing Studio returns to its normal state. enter image description here

Upvotes: 0

Hernan Guzman
Hernan Guzman

Reputation: 1235

Have you checked the default editor for your files?

Right click on form.cs file:

enter image description here

Select your desired editor an click the Set as default button

  • Csharp Form Editor: Opens your form on design view.
  • Csharp Editor: Opens your code view.

enter image description here

Upvotes: 2

Related Questions