[英]VS 2012 Designer could not be shown
我有一個UserControl類Employee_EmployeeKeyOneRelationUC
,該類繼承自RelationUC
,后者繼承自RelationBase
,后者繼承自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
它們都正確顯示。
我的程序仍在編譯,但是為什么這困擾着我? 因為我有一個使用很多UserControl
EmployeeForm
表單(例如Employee_EmployeeKeyOneRelationUC
),並且當我嘗試編輯此Form中的某些內容時,從UserControleBase
繼承的表單中包含的每個UserControl都將被刪除(左:TFS服務器,右:本地):
該差異表明設計者刪除了我的所有ucEmployee*
對象。 只是因為我更改了ComboBox的名稱(combobox與UC之一沒有關系)。
我注意到當我創建一個新的UserControl文件時,顯示的默認代碼有一個錯誤:
但是Using System.Windows.Forms;
就在那里。 如果我將UserControl
更改為System.Windows.Forms.UserControl
它將起作用。
我可能不太清楚,所以如果您有任何疑問,我將全天回答並測試。
在VS2010,VS2012 Update 1,VS2012 Update 2的3台不同計算機上進行了測試
在Form或Usercontrol中使用泛型時,建議您放置一個用於定義Generic類型的空類。 然后,您當前的表格從該類派生。
我將該類放在同一文件中。 它必須在實際的Form代碼之后,如下所示:
public partial class Employee_EmployeeKeyOneRelationUC
: Employee_EmployeeKeyOneRelation_GenericUC
{ ... }
public class Employee_EmployeeKeyOneRelation_GenericUC
: RelationUC<MyObject>
{ }
如果從VS2010加載C ++ CLR Winforms應用程序,則VS2013與表單設計器存在一個錯誤。 “無法顯示該文件的設計器,因為無法設計其中的所有類。”
如果更改並保存源文件,則表單設計器將再次開始工作。 但是它再次失敗,再次加載到項目中。 看起來就像在加載源文件和表單設計者解析代碼之間的競賽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.