poudigne
poudigne

Reputation: 1766

Losing UserControl when editing winForm VS2012

I have a Form called EmployeeForm inside this form i'm including some UserControl and when I edit EmployeeForm every UserControl inside the form are lost.

This picture show a diff between TFS(left) and Local(right) file, after modifying the name of a combobox

enter image description here

Example of this.ucEmployeeKeyOne :

public partial class Employee_EmployeeKeyOneRelationUC
    : Employee_EmployeeKeyOneRelation_GenericUC
{ [other Code Here] }

public class Employee_EmployeeKeyOneRelation_GenericUC
    : RelationUC<MyObject>
{ }

and the definition of RelationUC :

public partial class RelationUC<T>
    : DataUserControlBase
{ [other Code Here] }

public partial class DataUserControlBase
   : UserControlBase
{ [other Code Here] }

public partial class UserControlBase
   : System.Windows.Forms.UserControl, MyInterfaceHere
{ [other Code Here] }

All UserControl i'm losing are inherited from RelationUC<T>. Does the generic type of RelationUC may cause the problem?

Upvotes: 4

Views: 357

Answers (1)

Jegan
Jegan

Reputation: 1237

For the Vs designer to load the controls, the control should be able to initialize including all public properties and you must have a empty constructor. If you don't have an empty constructor or have properties that are returning from the inherited nullable class, it is most likely the the designer will crash.

To Debug this,

1) open you project in VS but do not open the file that contains the controls yet;

2) open another VS and attach the process of VS that your project is opened;

3) set the break on exceptions (short cut 'CTRL + D, CTRL +E' ) to all (once you become familiar with what exception the designer is throwing, you can set that exception only.);

4) Go to the VS with you project and open the file that contain your user control. when the exception is thrown, the second VS will catch it and tell you exactly why and where.

Upvotes: 3

Related Questions