ToolStrip
windows でオブジェクトを使い始めたばかりですForm
。
ツール ストリップを追加する方法、ボタンを追加する方法、ボタンに画像を割り当てる方法を説明する素敵なチュートリアルに従いました。
そこで、ツールストリップを追加してからボタンを追加しました。
ご覧のとおり、上のスクリーン ショットでは、画像のインポートも試みています。ボタンを右クリックしてSet Imageを選択することでこれを行いました:
[ OK] をクリックすると、これらの追加ファイル ( MyGenioViewer1.Designer.cs ) が自動的に生成されました。
しかし今、プロジェクトはコンパイルされません。以前のバックアップを復元し、ボタンのインポート以外のすべてを実行すると、コンパイルされます。
エラーは次のとおりです。
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;
}
}
}
}