Search code examples
c#visual-studiovisual-studio-2013

C# Class preview not available in Solutions Explorer


I have an issue with several of the C# files in my project.

When I click on the arrow next to the file name in the Solutions Explorer pane, the arrow disappears. For the rest of the files, clicking on the arrow unfolds a list of the classes inside the file. Also, when I open the file, the Project Dropdown under the file tabs shows "Miscellaneous Files" instead of the project name.

I have tried removing and re adding the files to the project, as well as closing and reopening Visual Studio.

How do I fix this?


Solution

  • This is caused by the Build Action being set to None instead of Compile

    There are two ways two do it:

    1. Select the file in the Solution Explorer pane. Click on the Build Action dropdown in the properties pane, and select Compile

    2. Open your .csproj, find the line that says <None Include="filename.cs" /> and change it to <Compile Include="filename.cs" />