user3200169 user3200169 - 6 months ago 17
C# Question

Why im getting error on the line InitializeComponent();?

I have this Usercontrol, I created and Im getting error on


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;

namespace RssNews
public partial class
FeederControl : UserControl
SpeechSynthesizer speaker;
Label[] list = new Label[5];
int jump = 0;
private IContainer components;

public string[] NewsTextFeed { get; set; }
public Color[] TextColor { get; set; }

private int _spacing = 10;
public int Spacing
get { return _spacing; }
set { _spacing = value; }

public void NewsFeederControl()
speaker = new SpeechSynthesizer();

The error/s:

Error 29 The call is ambiguous between the following methods or
properties: 'RssNews.FeederControl.InitializeComponent()' and

Then in the designer of the UserControl:

Error 31 Ambiguity between 'RssNews.FeederControl.components' and

This is the designer code:

namespace RssNews
partial class FeederControl
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
if (disposing && (components != null))

#region Component Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
// FeederControl
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.AntiqueWhite;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Name = "FeederControl";
this.Size = new System.Drawing.Size(146, 146);
this.Load += new System.EventHandler(this.FeederControl_Load);



private System.Windows.Forms.Timer timer1;

Im getting erorrs same error meassage on all components in the designer.cs code.
And also

Error 2 Type 'RssNews.FeederControl' already defines a member called
'InitializeComponent' with the same parameter types

This control is working good on another project i did same code. I just changed the namespaces names for this project. The one before was mws and this one is RssNews

How can i fix the errors ?

pid pid
Answer Source

First thing: you have a different constructor name then the class name. Second, have you tried to debug it? You posted way too much code. Trim it down to the relevant pieces.


You have 2 partials that are merged into one, and the function InitializeComponent() defined twice. You must define it only in one of the two partials. Keep it where VS put it.