Winform custom elements - constructor randomly stops initialization / constructor invocation

This is a terrible nightmare, and I desperately need help. I ALWAYS looked for help. NOTHING worked as a permanent solution.

I have some custom controls that I designed; controls that extend the button, user control, etc. I have a problem that VS2010 constantly and randomly, without any rhymes or reasons that I can distinguish, solves when I try to open a constructive view of a control that uses a custom control, strong> (EDIT: "it" is by the Windows Forms generator) must FULLY DELETE the LINE that calls the constructor for the user control from the .designer.cs file, thereby completely disrupting my ability to view the design view. The application is still building and working completely fine.

I tested and ruled out the following issues:

  • An open constructor - obviously, having a non-public constructor (internal, etc.) can cause such problems. I checked 100 times - ALL user controls have public constructors.

  • Empty constructors - in addition to public ones, should be empty.

  • It does not cause anything that may fail in the constructor - I reduced all the constructors for user controls to empty

     Name() { }
    calls. Bad luck.
  • Namespaces apparently in a different namespace can cause problems? I am in the same, and the files are in the same project.

  • Upload project. Close VS. Delete the .suo intellisense file. Delete obj files. Open VS. Reloading the project. Rebuild the project. Still out of luck.

. , , . , ?

+3
1

-, ... ".designer.cs"... . Microsoft. WinForms , "",

MyForm.cs   (place for YOUR code)
   MyForm.designer.cs  (Microsoft sandbox area for designer stuff)
   MyForm.resx   (Resource file -- if used, specific to this form).

, WinForm "" " ", MyForm.cs.

PARTIAL PUBLIC CLASS MyForm : Window
{
   public MyForm()
   {
      InitializeComponent();
   }
}

"MyForm.Designer.cs" "MyForm.cs" . Microsoft. , , . - , , - , . ( ).

   public MyForm()
   {
      DoYourStuff();
      InitializeComponent();
      // or DoYourStuff here after designer controls are all initialized.
   }

   private void DoYourStuff()
   {  put it here }

- , . , LOADED ( , ). - :

public MyForm()
{

   Load += MyAfterInitializeComponents;
   InitializeComponent();
}


private void MyAfterInitializeComponents(object sender, EventArgs e)
{  
   DoYourStuff(); 
}

- , , , , .

+3

All Articles