Reputation: 1766
I have a UserControl class Employee_EmployeeKeyOneRelationUC
that inherit from RelationUC
that inherit from RelationBase
that inherit from System.Window.Forms.UserControl
When I try to open my Employee_EmployeeKeyOneRelationUC
in the Designer I have this error :
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.
But when I open RelationUC
and RelationBase
both are showing up correctly.
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) :
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).
I have notice that when I create a new UserControl file the default code showing up has an error :
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.
Tested on 3 different computer with VS2010, VS2012 Update 1, VS2012 Update 2
Upvotes: 1
Views: 3455
Reputation: 11
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.
Upvotes: 1
Reputation: 364
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>
{ }
Upvotes: 4