1

我有一个Employee_EmployeeKeyOneRelationUC继承自RelationUC该继承自RelationBase该继承自的 UserControl 类System.Window.Forms.UserControl

当我尝试Employee_EmployeeKeyOneRelationUC在设计器中打开我的时,出现此错误:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: Employee_EmployeeKeyOneRelationUC --- The base class 'AstusFMS.Content.RelationUC' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.

但是当我打开RelationUC并且RelationBase两者都正确显示时。

我的程序仍在编译,但为什么这让我感到困扰?因为我有一个EmployeeForm使用很多UserControl(如Employee_EmployeeKeyOneRelationUC)的表单,当我尝试编辑此表单中的某些内容时,表单中包含的每个继承自的 UserControl 都将UserControleBase被删除(左:TFS 服务器,右:本地):

EmployeeForm.Designer.cs 的差异(左:TFS 服务器,右:本地)

这个差异表明设计师删除了我所有的ucEmployee*对象。仅仅因为我更改了 ComboBox 的名称(组合框与其中一个 UC 无关)。

我注意到,当我创建一个新的 UserControl 文件时,显示的默认代码有一个错误: 默认用户控件有错误

但它就在Using System.Windows.Forms;那里。如果我改变它的UserControl工作System.Windows.Forms.UserControl原理。

我可能不够清楚,所以如果你有问题,我会整天回答和测试。

用 VS2010、VS2012 更新 1、VS2012 更新 2 在 3 台不同的计算机上测试

4

2 回答 2

4

在 Form 或 Usercontrol 中使用泛型时,建议您放置一个定义 Generic 类型的空类。您当前的 Form 然后派生自该类。

我把那个类放在同一个文件中。它必须在实际的表单代码之后,如下所示:

  public partial class Employee_EmployeeKeyOneRelationUC
    : Employee_EmployeeKeyOneRelation_GenericUC
  { ... }

  public class Employee_EmployeeKeyOneRelation_GenericUC
    : RelationUC<MyObject>
  { }
于 2013-04-18T17:45:20.823 回答
1

VS2013 has a a bug with the form designer if you load in from VS2010 a C++ CLR Winforms app. "The designer could not be shown for this file because none of the classes within it can be designed. "

If you change and save the source file then the form designer starts to work again. But it fails again on loading in the project again. Looks like a race between loading the source file and the form designer parsing the code.

于 2014-06-03T02:09:43.607 回答