缺少调试目标,Visual Studio无法开始调试

用visual studio 2005做一个文本编辑器,在网上找到代码,自己修改后调试,结果出现下面的问题:由于缺少调试目标"路径...\bin\debug\txt.exe",Visual Studio无法开始调试,请生成项目并重试,或者相应地设置outputpath和assemblyname属性,使其指向目标程序集的正确位置。"
错误 1 “Txt.Form1.Dispose(bool)”: 没有找到适合的方法来重写 文件:D:\Studying\Chou‘s Homework\数据结构大作业\文本编辑器\Txt\Txt\Form1.Designer.cs
错误 2 程序“D:\Studying\Chou‘s Homework\数据结构大作业\文本编辑器\Txt\Txt\obj\Debug\Txt.exe”定义了不止一个入口点:“Txt.Program.Main()” 文件:Program.cs

错误 3 程序“D:\Studying\Chou‘s Homework\数据结构大作业\文本编辑器\Txt\Txt\obj\Debug\Txt.exe”定义了不止一个入口点:“Txt.FormMain.Main()” 文件:D:\Studying\Chou‘s Homework\数据结构大作业\文本编辑器\Txt\Txt\Form1.cs
出错代码处:
Form1.cs:
public class FormMain : System.Windows.Forms.Form
{
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
...}
[STAThread]
static void Main()
{
Application.Run(new FormMain());
}
Program.cs:
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}

Form1.Designer.cs:
partial class Form1
{
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
}

第1个回答  推荐于2017-09-17
错误1,不要随便改动你的Designer文件,里面的代码都是自动生成的,不需要你做改写。

错误2和错误3,你在一个项目中定义了两个入口Main函数,使得编译器无法判断从哪个Main入口。建议你删除Form1.cs中的Main函数,然后将Program.cs中的Main函数改成:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}本回答被提问者采纳
第2个回答  2008-05-25
你写了两个Main函数.Main函数只能有一 个.
相似回答