VS 2012 Designer无法显示 [英] VS 2012 Designer could not be shown

查看:850
本文介绍了VS 2012 Designer无法显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a UserControl class Employee_EmployeeKeyOneRelationUC that inherit from RelationUC that inherit from RelationBase that inherit from System.Window.Forms.UserControl

当我尝试打开我的设计师中的 Employee_EmployeeKeyOneRelationUC 我有这个错误:

When I try to open my Employee_EmployeeKeyOneRelationUC in the Designer I have this error :

设计师无法显示这个文件是因为它中没有一个类可以被设计。设计师在文件中检查以下类:Employee_EmployeeKeyOneRelationUC ---无法加载基类AstusFMS.Content.RelationUC。确保装配已被引用,并且所有项目都已经被构建。

但是当我打开 RelationUC RelationBase 都正确显示。

But when I open RelationUC and RelationBase both are showing up correctly.

我的程序仍然编译,但为什么这会打扰我?因为我有一个表单 EmployeeForm ,它使用了很多 UserControl (如 Employee_EmployeeKeyOneRelationUC UserControleBase 继承的表单中包含的每个UserControl(左侧:TFS服务器,右侧:本地):

My program still compiling but why this is bothering me ? Because I have a form EmployeeForm that use a lot of UserControl (like Employee_EmployeeKeyOneRelationUC) and when I try to edit something in this Form, every UserControl included in the form that inherit from UserControleBase are deleted (left: TFS Server, right: local) :

此差异显示设计器删除了我所有的 ucEmployee * 目的。只是因为我更改了ComboBox的名称(组合框与UC之一没有任何关系)。

This diff is showing that the designer deleted all my ucEmployee* object. Just because I change a ComboBox's name (combobox has no relation with one of the UC).

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

I have notice that when I create a new UserControl file the default code showing up has an error :

但是,使用System.Windows.Forms; 就在那里。如果我为 System.Windows.Forms.UserControl 更改 UserControl ,它可以工作。

But the Using System.Windows.Forms; is right there. If I change the UserControl for System.Windows.Forms.UserControl it works.

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

I may not be clear enough so if you have question, i'll be on to answer and test all day.

经过3个不同的测试计算机与VS2010,VS2012更新1,VS2012更新2

Tested on 3 different computer with VS2010, VS2012 Update 1, VS2012 Update 2

推荐答案

当在Form或Usercontrol中使用泛型时,建议您定义泛型的空类。您当前的表单然后来自该类。

When using generics inside Form or Usercontrol, it's recommended that you put an empty class that define the Generic type. Your current Form then derives from that class.

我把该类放在同一个文件中。它必须遵循这样的实际表单代码:

I put that class inside the same file. It has to be after the actual Form code like this:

  public partial class Employee_EmployeeKeyOneRelationUC
    : Employee_EmployeeKeyOneRelation_GenericUC
  { ... }

  public class Employee_EmployeeKeyOneRelation_GenericUC
    : RelationUC<MyObject>
  { }

这篇关于VS 2012 Designer无法显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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