Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Buttons, RadioButton, CheckBox, etc > System.InvalidOperationException: Control already added!

Not answered System.InvalidOperationException: Control already added!

Feed from this thread
  • William avatar

    Posted on Jan 5, 2012 (permalink)

    Hello, I am very new to Telerik, but others in my group have been using it for some time and nobody else experiences this issue and cannot reproduce this issue.

    I am modifying a GUI that has been generated by another engineer, simply, I am moving a button by only a couple of pixels and the VS2010 designer changes nearly a hundred of lines of code in the designer.cs file.  But they only lines of code that prevent the GUI from displaying are included here, and at the bottom of the message is the exception that occurs at run-time.

    Original Code (Bold code is removed by the VS designer/Telerik after button is moved):
                // 
                // radScrollablePanel1
                // 
                this.radScrollablePanel1.AutoScroll = true;
                this.radScrollablePanel1.AutoScrollMargin = new System.Drawing.Size(0, 0);
                this.radScrollablePanel1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
                this.radScrollablePanel1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radScrollablePanel1.Location = new System.Drawing.Point(0, 0);
                this.radScrollablePanel1.Name = "radScrollablePanel1";
                this.radScrollablePanel1.Padding = new System.Windows.Forms.Padding(1);
                // 
                // radScrollablePanel1.PanelContainer
                // 
                this.radScrollablePanel1.PanelContainer.AutoScroll = true;
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel8);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel14);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel1);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel13);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel2);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel12);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel3);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel11);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel4);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel10);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel5);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel9);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel6);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.label12);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.panel7);
                this.radScrollablePanel1.PanelContainer.Controls.Add(this.GeneralQryResultRichTextBox);
                this.radScrollablePanel1.PanelContainer.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radScrollablePanel1.PanelContainer.Location = new System.Drawing.Point(1, 1);
                this.radScrollablePanel1.PanelContainer.Name = "PanelContainer";
                this.radScrollablePanel1.PanelContainer.Size = new System.Drawing.Size(940, 530);
                this.radScrollablePanel1.PanelContainer.TabIndex = 0;


    After Modification of the button control (Bold code is added by the VS/Telerik after button is moved): 
                // 
                // radScrollablePanel1
                // 
                this.radScrollablePanel1.AutoScrollMargin = new System.Drawing.Size(0, 0);
                this.radScrollablePanel1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
                this.radScrollablePanel1.Controls.Add(this.radScrollablePanel1.PanelContainer);
                this.radScrollablePanel1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radScrollablePanel1.Location = new System.Drawing.Point(0, 0);
                this.radScrollablePanel1.Name = "radScrollablePanel1";
                this.radScrollablePanel1.Padding = new System.Windows.Forms.Padding(1);



    During runtime I get this exception at the Bolded line in the "After" section:
    *** [05 Jan 2012 10:17:25.701 WSApp     ] [ERROR] System.ApplicationException: Unable to create an instance of the B.WS.SnapIn.RV.RVControlSnapIn plugin in the assembly named B.WS.SnapIn.RV. 
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Control already added!
       at Telerik.WinControls.UI.RadScrollablePanelControlCollection.Add(Control value)
       at B.WS.SnapIn.RV.RVControlSnapIn.InitializeComponent() in C:\_dev\VS\Main\S\Apps\WS Apps\Libs\B.WS.SnapIn.RV\RVControlSnapIn.designer.cs:line 1755
       at B.WS.SnapIn.RV.RVControlSnapIn..ctor() in C:\_dev\VS\Main\S\Apps\WS Apps\Libs\B.WS.SnapIn.RV\RVControlSnapIn.cs:line 41
       --- End of inner exception stack trace ---
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
       at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at B.NE.PluginFramework.PluginManager.LoadPlugin(String typeName, String path, Hashtable parameters) in C:\_dev\VS\Main\S\SLibs\B.NE.PluginFramework\PluginManager.cs:line 438 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Control already added!
       at Telerik.WinControls.UI.RadScrollablePanelControlCollection.Add(Control value)
       at B.WS.SnapIn.RV.RVControlSnapIn.InitializeComponent() in C:\_dev\VS\Main\S\Apps\WS Apps\Libs\B.WS.SnapIn.RV\RVControlSnapIn.designer.cs:line 1755
       at B.WS.SnapIn.RV.RVControlSnapIn..ctor() in C:\_dev\VS\Main\S\Apps\WS Apps\Libs\B.WS.SnapIn.RV\RVControlSnapIn.cs:line 41
       --- End of inner exception stack trace ---
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
       at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at System.Activator.CreateInstance(Type type)
       at B.NE.PluginFramework.PluginManager.LoadPlugin(String typeName, String path, Hashtable parameters) in C:\_dev\VS\Main\S\SLibs\B.NE.PluginFramework\PluginManager.cs:line 438
       --- End of inner exception stack trace ---
       at B.NE.PluginFramework.PluginManager.LoadPlugin(String typeName, String path, Hashtable parameters) in C:\_dev\VS\Main\S\SLibs\B.NE.PluginFramework\PluginManager.cs:line 461
       at WSContainer.WSContainerNode.AddPlugin(String typeName, String path, Hashtable parameters) in C:\_dev\VS\Main\S\Apps\WS Apps\WSContainer\WSContainerNode.cs:line 133
       at WSContainer.WSApp.LoadPlugin(Guid id, String typeName, String path) in C:\_dev\VS\Main\S\Apps\WS Apps\WSContainer\WSApp.cs:line 792

    Reply

  • Stefan Stefan admin's avatar

    Posted on Jan 9, 2012 (permalink)

    Hello,

    Your question has already been answered in the support her thread you have opened. Please, see our answer there for more information.

    We kindly ask you to use just one support channel to contact us. Posting the same questions several times slows down our response time, because we need to review and address two or more tickets instead of one. Support tickets are handled according to license and time of posting, so if it is an urgent issue, we suggest you directly open a support ticket, which would be handled before a forum thread.

    Thank you for your understanding.

    Kind regards,
    Stefan
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Buttons, RadioButton, CheckBox, etc > System.InvalidOperationException: Control already added!
Related resources for "System.InvalidOperationException: Control already added!"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]