Visual Studio Design View - form is blank

Your project file has become invalid.

A valid project entry for a form looks like this:

<Compile Include="Form1.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
  <DependentUpon>Form1.cs</DependentUpon>
</Compile>

Yours though is missing the DependentUpon line - which is why the code and designer files appear separately in the project, instead of being connected:

<Compile Include="mainForm.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="mainForm.Designer.cs" />

If you add in the missing line, the form displays correctly in design mode:

<Compile Include="mainForm.cs">
  <SubType>Form</SubType>
</Compile>
<Compile Include="mainForm.Designer.cs">
  <DependentUpon>mainForm.cs</DependentUpon>
</Compile>

And to tidy up the resource file:

<EmbeddedResource Include="mainForm.resx">
  <DependentUpon>mainform.cs</DependentUpon>
</EmbeddedResource>

In order to fix this, you can just edit the csproj in an editor, or to do it in Visual Studio:

  1. Back up the files
  2. Right-click the project and choose "Unload Project"
  3. Right-click the unloaded project and choose "Edit [ProjectName].csproj"
  4. Make your changes, and close the file.
  5. Right-click the unloaded project and choose "Reload Project"

I solved the problem by removing all files associated with that form

  • File -> Right-click -> Exclude from Project

and adding the files manually back to the project

  • Project -> Add -> Existing Item...