2016-05-27 17 views
0

私のウィンドウにToolStripオブジェクトを使用し始めたばかりです。Formツールストリップボタンのボタンイメージをインポートした後にプロジェクトビルドエラーが発生する

私は、ツールストリップを追加してからボタンを追加し、次にボタンに画像を割り当てる方法を説明した素敵なチュートリアルに続きました。

だから、私はのToolStripを追加し、ボタンを追加しました:私もイメージをインポートしようとした上記のスクリーンショットでは、

Add button to toolstrip

あなたが見ることができるようにします。私はOKをクリックすると、これらの余分なファイル(MyGenioViewer1.Designer.cs)が自動的に生成された

Import button

:私は、ボタンを右クリックしてセットのイメージを選択することによってこれをしなかった

Extra files created

しかし、プロジェクトはコンパイルされません。以前のバックアップを復元して、すべてを除く)を実行すると、それはコンパイルされます。

これらはエラーです:

Severity Code Description Project File Line Suppression State 
Error CS0111 Type 'MyGenioView' already defines a member called '.ctor' with the same parameter types GENIO Viewer D:\My Programs\GENIO Viewer\GENIO Viewer\MyGenioView.cs 65 Active 
Error CS0262 Partial declarations of 'MyGenioView' have conflicting accessibility modifiers GENIO Viewer D:\My Programs\GENIO Viewer\GENIO Viewer\MyGenioView.Designer.cs 25 Active 
Error CS0260 Missing partial modifier on declaration of type 'MyGenioView'; another partial declaration of this type exists GENIO Viewer D:\My Programs\GENIO Viewer\GENIO Viewer\MyGenioView1.Designer.cs 25 Active 
Error CS0111 Type 'MyGenioView' already defines a member called '.ctor' with the same parameter types GENIO Viewer D:\My Programs\GENIO Viewer\GENIO Viewer\MyGenioView1.Designer.cs 32 Active 
Error CS0121 The call is ambiguous between the following methods or properties: 'MyGenioView.MyGenioView()' and 'MyGenioView.MyGenioView()' GENIO Viewer D:\My Programs\GENIO Viewer\GENIO Viewer\GENIO_Viewer_Form.cs 53 Active 

は明らかに、これらの余分なファイルの追加は、私に問題がありました。彼らがなぜ追加されたのかわかりません。私はこの問題の解決方法を知らない。そして私はそれを防ぐ方法を知らない。

この問題を正しく解決していただきありがとうございます。

MyGenioView.Designer.csは含まれています

namespace GENIO_Viewer 
{ 
    partial class MyGenioView 
    { 
    /// <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.SuspendLayout(); 
     // 
     // MyGenioView 
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
     this.Name = "MyGenioView"; 
     this.ResumeLayout(false); 

    } 

    #endregion 
    } 
} 

新しいMyGenioView1.Designer.cs原因の問題です:あなたがここに本当の混乱を持って

//------------------------------------------------------------------------------ 
// <auto-generated> 
//  This code was generated by a tool. 
//  Runtime Version:4.0.30319.42000 
// 
//  Changes to this file may cause incorrect behavior and will be lost if 
//  the code is regenerated. 
// </auto-generated> 
//------------------------------------------------------------------------------ 

namespace GENIO_Viewer { 
    using System; 


    /// <summary> 
    /// A strongly-typed resource class, for looking up localized strings, etc. 
    /// </summary> 
    // This class was auto-generated by the StronglyTypedResourceBuilder 
    // class via a tool like ResGen or Visual Studio. 
    // To add or remove a member, edit your .ResX file then rerun ResGen 
    // with the /str option, or rebuild your VS project. 
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 
    internal class MyGenioView { 

     private static global::System.Resources.ResourceManager resourceMan; 

     private static global::System.Globalization.CultureInfo resourceCulture; 

     [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 
     internal MyGenioView() { 
     } 

     /// <summary> 
     /// Returns the cached ResourceManager instance used by this class. 
     /// </summary> 
     [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 
     internal static global::System.Resources.ResourceManager ResourceManager { 
      get { 
       if (object.ReferenceEquals(resourceMan, null)) { 
        global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GENIO_Viewer.MyGenioView", typeof(MyGenioView).Assembly); 
        resourceMan = temp; 
       } 
       return resourceMan; 
      } 
     } 

     /// <summary> 
     /// Overrides the current thread's CurrentUICulture property for all 
     /// resource lookups using this strongly typed resource class. 
     /// </summary> 
     [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 
     internal static global::System.Globalization.CultureInfo Culture { 
      get { 
       return resourceCulture; 
      } 
      set { 
       resourceCulture = value; 
      } 
     } 
    } 
} 

答えて

1

。どういうわけか、あなたはFormとは別のデザイナーファイルを持っています。実際、デザイナーファイルのようには見えません。私があなたのスクリーンショットで見なかったのは、それらのデザイナーがリンクされていると思われるフォームでした。

それは次のようになります。

enter image description here

をあなたはこのクラスのコードは表示されませんでした:MyGenioView.csを、私はそれが既にMyGenioView1.Designer.csにあるものの少なくとも一部を定義する推測しています。

最終行は、あまりにも多くの箇所に衝突する(部分的に)クラスが多すぎるということです。 MyGenioViewのクラス(コードページ)とフォームのクラス(コードページ)が必要です。それ以外は矛盾しています。

P.S.また、WPFのコンストラクトをWinFormsと混同しているのではないかと思います。彼らは大きく異なっています。「View」という言葉を使用すると、私にこれが示唆されました。私は間違っているかもしれません。

+0

実際のフォームは1つのみです。しかし、あなたが言ったことは、私のプロジェクトの一部がどこから来たのかを考えさせました。だから、私は冗長な** resx/designer **ファイルを削除し、元のCSでは 'InitializeComponent'呼び出しを削除しました(とにかくフォームがないので)。 :) –

+0

私はWinFormsを使用しています。私はWPFを一度も使用していません。私は単にMFCの背景のために用語の表示を使用します。派生したUserControlオブジェクトの名前をビューとして変更しました。それがすべてだった。 WPFは未知の領域です。 :) –

関連する問題