using System;
using System.Windows.Forms;namespace _05_08
{
    public class Form_05_08 : Form
    {
        public Form_05_08()
        {
            this.Click += new EventHandler(this.Form_Click);
        }
        public void Form_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked!");
        }    }
    public class Class_05_08
    {
        public static void Main(String[] args)
        {
            Application.Run(new Form_05_08());
        }
    }
}错误 1 “WindowsApp1.Form1.Dispose(bool)”: 没有找到适合的方法来重写 D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.Designer.cs 14 33 WindowsApplication2
错误 2 程序“D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.exe”定义了不止一个入口点:“WindowsApplication2.Program.Main()” D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Program.cs 13 21 WindowsApplication2
错误 3 程序“D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\obj\Debug\WindowsApplication2.exe”定义了不止一个入口点:“_05_08.Class_05_08.Main(string[])” D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.cs 20 28 WindowsApplication2
怎么回事情啊 我点下面的报错 就在Main下有条红线

解决方案 »

  1.   

    D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.cs
    里也包括个Main ,去掉一个
      

  2.   

    lz:
    那我还想请问怎么删除呢 是删除哪一个呢
    是删除代码段 还是单词Main??
    可以具体点么?
      

  3.   

    把下面的代码去掉或者该个名 public class Class_05_08
        {
            public static void Main(String[] args)
            {
                Application.Run(new Form_05_08());
            }
        }
      

  4.   

    把下面的代码去掉或者该个名 public class Class_05_08\
    改名或者去掉 出现新错误
    错误 1 “_05_08.Form1”并不包含“AutoScaleMode”的定义 D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.Designer.cs 24 18 WindowsApplication2
    错误 2 “_05_08.Form1”并不包含“Text”的定义 D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.Designer.cs 25 18 WindowsApplication2
    错误 3 找不到类型或命名空间名称“Form1”(是否缺少 using 指令或程序集引用?) D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Program.cs 17 33 WindowsApplication2
    错误 4 与“System.Windows.Forms.Application.Run(System.Windows.Forms.Form)”最匹配的重载方法具有一些无效参数 D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Program.cs 17 13 WindowsApplication2
    错误 5 参数“1”: 无法从“Form1”转换为“System.Windows.Forms.Form” D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Program.cs 17 29 WindowsApplication2
      

  5.   

    你的Main方法上缺少[STAThread].请问是什么意思 是要改成[STAThread].Main???
      

  6.   

    你的namespace _05_08中有其它頁面中也存在main,所以會出錯。
    和[STAThread]沒有關系。
      

  7.   

    VS2005代码
    Form1.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace _05_08
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("You clicked!");// this.Click += new System.EventHandler(this.Form1_Click);位于Form1.Designer.cs 中
            }
        }
    }Form1.Designer.csnamespace _05_08
    {
        partial class Form1
        {
            /// <summary>
            /// 必需的设计器变量。
            /// </summary>
            private System.ComponentModel.IContainer components = null;        /// <summary>
            /// 清理所有正在使用的资源。
            /// </summary>
            /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }        #region Windows 窗体设计器生成的代码        /// <summary>
            /// 设计器支持所需的方法 - 不要
            /// 使用代码编辑器修改此方法的内容。
            /// </summary>
            private void InitializeComponent()
            {
                this.SuspendLayout();
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(292, 266);
                this.Name = "Form1";
                this.Text = "Form1";
                this.Click += new System.EventHandler(this.Form1_Click);
                this.ResumeLayout(false);        }        #endregion
        }
    }Program.csusing System;
    using System.Collections.Generic;
    using System.Windows.Forms;namespace _05_08
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }
    }
      

  8.   

    我用的vs2005 我运行的时候是多出来2个文件 program.cs Form1.Designer.cs
    program.cs里面是有一个
    [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
      

  9.   

    我的是2005  lizhizhe2000(彬彬还有一个错误 
    错误 1 当前上下文中不存在名称“InitializeComponent” D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.cs 15 13 WindowsApplication2
      

  10.   

    program.cs 和Form1.Designer.cs
    是必须的,窗体程序中Program.cs是主文件,Form1.Designer.cs
    是由IDE用来布置可视化处理
      

  11.   

    错误 1 当前上下文中不存在名称“initializeComponent” D:\Program Files\MyC\WindowsApplication2\WindowsApplication2\Form1.cs 15 13 WindowsApplication2
      

  12.   

    program.cs不是必须的, main函数才是必须的
      

  13.   

    scow(怡红快绿) 兄台的说法是正确的,也可以把Main()放到Form1中
    如下:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace _05_08
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("You clicked!");// this.Click += new System.EventHandler(this.Form1_Click);位于Form1.Designer.cs 中
            }
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
        }
    }