Designer error

I recieve the following set of errors in the designer tab when I try and compile my program. I am new at using Windows Forms. I know you are not supposed to write code in the automatically generated code, but I don't know where else to put it. Could this be the problem

C++ CodeDOM parser error: Internal Error
Hide

at Microsoft.VisualC.CppCodeParser.OnMethodPopulateStatements(Object sender, EventArgs e)
at System.CodeDom.CodeMemberMethod.get_Statements()
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)



Answer this question

Designer error

  • ianpender

    anywhere outside, in your OnLoad override, eventhandlers, etc.


  • kanjo

    Probably in the constructor

  • Buruburu

    You shouldn't be declaring variables in InitializeComponent; that's the whole point. You shouldn't be writing AND code in InitializeComponent. If you are referencing class level variables, even if they are declared in the designer file, they are still accessible in the constructor.

  • garimell

    When I write my own code in the constructor, and I want to use variables that I created in the Initialize component region, the compiler doesn't recognize the variable. error C2065 'variable' undeclared identifier

  • Josh Smith

    you are not supposed to put code in the automatically generated part, like in the initialize component method.

    suppose, you put the following code in initialize component
    this->Text = count;
    you get an error window on the desinger similar to this though the error description might be different

    if you put the following code
    this->Text = "Text1";
    the code is valid and you see the form caption change to "Text1".


    Now suppose you add a button to the form by dragging from the toolbox, all the changes you made to the code are gone (like the statement above this->Text = "Text1").



  • KipK

    Where am I supposed to put the code that I write

  • Designer error