2014-01-26 1 views
0

나는 내가 만든이 UserControl을을 가지고 임 오류/s의 InitializeComponent왜 내가 라인 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(); 
     } 

에 오류가 'RssNews :

오류 29 호출은 다음과 같은 방법 또는 속성 사이의 모호합니다. FeederControl.InitializeComponent() '와 'RssNews.FeederControl.InitializeComponent() '는 UserCon의 디자이너 그리고

트롤 :

오류 'RssNews.FeederControl.components'와 사이 31 모호성 '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; 
    } 
} 

임 점점 erorrs designer.cs 코드의 모든 구성 요소에 동일한 오류가 발생했습니다. 그리고 또한

오류 2 유형 'RssNews.FeederControl'이 (가) 이미 회원이이 컨트롤은 내가 동일한 코드를했던 다른 프로젝트에 좋은 작동하고 같은 파라미터 형

와 '의 InitializeComponent을'이라고 정의한다. 방금이 프로젝트의 네임 스페이스 이름을 변경했습니다. 이전 하나는 mws이고이 하나는 RssNews입니다.

오류를 해결하려면 어떻게해야합니까?

+2

UserControl에 대한 * Designer.cs 소스 파일이 두 개있는 것 같습니다. 어떻게 그렇게했는지 짐작하기 어렵습니다 :) 그 중 하나를 삭제하십시오. 생성자에서 InitializeComponent()를 호출하지 않으면 후회할 또 다른 문제가 발생합니다. 디자이너에서 제대로 작동하지 않습니다. –

답변

2

첫 번째 사항 : 생성자 이름과 클래스 이름이 다릅니다. 둘째, 디버깅을 시도 했습니까? 너무 많은 코드를 게시했습니다. 해당 부분을 자릅니다.

솔루션 :

당신은이 하나로 병합 파셜, 두 번 정의 된 함수의 InitializeComponent()를 가지고있다. 두 개의 부분 중 하나에서만 정의해야합니다. VS가 넣은 곳에 보관하십시오.

관련 문제