I have a C# project with two forms. All compiles well. When I run the project, all forms are drawn as they are expected to.
A couple of days back, the DesignView of all forms started to shown nothing but a blank form, like the one you get in a new Windows.Forms project.
I went through several questions on SO with a similar problem, here are the comments to those questions:
Is there something I could have messed up in the project settings or somewhere else?
EDIT
The third point above is misleading - I tried creating a new project for the second form as well and there the problem persist. The minimal amount of source code that shows the problem is to to be found here.
For those searching around and finding no solace, I have another solution. The project I inherited has horrible code quality and the previous developer had mixed case all over his code because "It's case insensitive, so it doesn't matter"
So, while PopulateRevs
is, in fact, identical to POpulateREvs
in Visual Basic, that kind of laziness leads to issues. To wit:
<Compile Include="Inventory\Partmaster.Designer.Vb">
<DependentUpon>Partmaster.vb</DependentUpon>
</Compile>
<Compile Include="Inventory\Partmaster.vb">
<SubType>Form</SubType>
</Compile>
I happened to see this in the .vbproj
file while looking at other solutions that didn't work. I happened to change Partmaster.Designer.Vb
to Partmaster.Designer.vb
(lowercase extension) and it worked.
So as another solution, while Visual Basic is not case sensitive, it looks like the .vbproj
file is. If you're stumped, another thing to make sure is that your file names and .proj
files share the same case.
(I realize this is tagged C#
, but I tested this in C# and the mixed case will cause problems there as well.)
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With