У меня есть этот UserControl, я создал и Im получаю ошибку на InitializeComponent
Почему im получает ошибку на линии InitializeComponent() ;?
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()
{
InitializeComponent();
speaker = new SpeechSynthesizer();
Init();
}
Ошибка/s:
Ошибка 29 Вызов неоднозначен между следующими методами или свойствами: «RssNews. FeederControl.InitializeComponent()»и 'RssNews.FeederControl.InitializeComponent()'
Тогда в конструкторе UserCon Троль:
Ошибка 31 неоднозначность между 'RssNews.FeederControl.components' и ' RssNews.FeederControl.components'
Это код дизайнер:
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))
{
components.Dispose();
}
base.Dispose(disposing);
}
#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);
this.SuspendLayout();
//
// 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);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Timer timer1;
}
}
Im получая erorrs то же самое об ошибках в отношении всех компонентов в коде designer.cs. А также
Ошибка 2 Тип «RssNews.FeederControl» уже определяет элемент называется «InitializeComponent» с теми же типами параметров
Этот контроль работает хорошо на другом проекте я сделал тот же код. Я просто изменил имена пространств имен для этого проекта. Первый был mws, и этот RssNews
Как я могу исправить ошибки?
Похоже, у вас есть * два исходных файла Designer.cs для UserControl. Трудно догадаться, как вы это сделали: Удалите один из них. Не ссылаться на InitializeComponent() в конструкторе - это еще одна вещь, о которой вы пожалеете, это не будет хорошо работать в дизайнере. –