Visual Studio Design View - form is blank

后端 未结 6 1154
别跟我提以往
别跟我提以往 2021-02-04 14:38

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

6条回答
  •  长发绾君心
    2021-02-04 15:29

    Your project file has become invalid.

    A valid project entry for a form looks like this:

    
      Form
    
    
      Form1.cs
    
    

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

    
      Form
    
    
    

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

    
      Form
    
    
      mainForm.cs
    
    

    And to tidy up the resource file:

    
      mainform.cs
    
    

    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"

提交回复
热议问题