Visual Studio的设计视图 - 形式是空白 [英] Visual Studio Design View - form is blank

查看:134
本文介绍了Visual Studio的设计视图 - 形式是空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种形式C#项目。所有编译好。当我运行该项目,因为他们预计所有形式的绘制。

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.

几天回来,的DesignView 所有的形式开始显示只是一个空白表格,就像一个你在一个新的获取Windows.Forms的项目。

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.

我通过SO几个问题给出了类似的问题了,这里有对这些问题的意见:

I went through several questions on SO with a similar problem, here are the comments to those questions:


  1. 有我的计划用途(除了htmlAgilityPack,不会引起其他Windows.Forms的C#项目这个问题)

  2. 我已经检查没有第三方库该InitializeComponent函数只有一次在项目的每个表单

  3. 当我创建一个新的项目并添加现有的形式(即我有问题的项目形式之一),设计浏览器的工作原理预期 - 因此我怀疑的.cs,和了.Designer.cs我的形式.resx文件都OK。

有什么我可以在项目设置搞乱了还是别的地方?

Is there something I could have messed up in the project settings or somewhere else?

修改

第三个点以上是误导 - 我试图创建第二个组成一个新的项目,以及有问题坚持。显示该问题的源代码中的最小量是被发现

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.

推荐答案

您的项目文件已失效。

对于形成有效的项目条目是这样的:

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>



此致虽然缺少DependentUpon行 - 这就是为什么代码和设计文件的项目单独出现,而不是被连接的:

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>

和整理的资源文件:

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

为了解决这个问题,你可以在编辑器中编辑的csproj,还是做这件事Visual Studio的:

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


  1. 备份文件

  2. 右键单击该项目,然后选择卸载项目

  3. 右键单击该项目卸载,然后选择编辑[项目]的.csproj

  4. 请更改,并关闭文件。

  5. 右键单击该卸载项目,然后选择刷新工程

  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"

这篇关于Visual Studio的设计视图 - 形式是空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆