关于程序 ChatServer.exe 定义了不止一个入口点:“ChatServer.Program.Main()”问题
各位大哥大姐您们好
小弟最近做毕业设计聊天系统时,遇到个问题
写好一个窗口后老是说有2个错误
错误 1 程序“F:\ChatServer\ChatServer\obj\Debug\ChatServer.exe”定义了不止一个入口点:“ChatServer.Program.Main()” F:\ChatServer\ChatServer\Program.cs 13 21 ChatServer
错误 2 程序“F:\ChatServer\ChatServer\obj\Debug\ChatServer.exe”定义了不止一个入口点:“ChatServer.ClientServerForm.Main()” F:\ChatServer\ChatServer\Form1.cs 177 21 ChatServer
以下是源代码,希望有人能解答~~万分感谢
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace ChatServer
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class ClientServerForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtHost;
private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.ComboBox CuruserList;
private System.Windows.Forms.ListBox lstInfo;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
//该服务器默认的监听端口号
static int port = 1234;
private TcpListener listener;
private Socket tmpSocket;
//服务器可以支持的最多客户端连接数
static int MaxNum = 100;
//clients数组保存当前在线用户的Clients对象
static ArrayList clients = new ArrayList();
public ClientServerForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
//TODO;Add any constructor code after LnitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used..
/// </summary>
protected override void Dispose( bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Disposing();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contens of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtHost = new System.Windows.Forms.TextBox();
this.txtPort = new System.Windows.Forms.TextBox();
this.btnStart = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.CuruserList = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.lstInfo = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
//label1
//
this.label1.Location = new System.Drawing.Point(0, 16);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "主机号";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
//label2
//
this.label2.Location = new System.Drawing.Point(0, 48);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "端口号";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
//txtHost
//
this.txtHost.Location = new System.Drawing.Point(120.16);
this.txtHost.Name = "txtHost";
this.txtHost.TabIndex = 2;
this.txtHost.Text = "";
//
//txtPort
//
this.txtPort.Location = new System.Drawing.Point(120.48);
this.txtPort.Name = "txtPort";
this.txtPort.ReadOnly = ture;
this.txtPort.TabIndex = 3;
this.txtPort.Text = "";
//
//btnStart
//
this.btnStart.Location = new System.Drawing.Point(232, 16);
this.btnStart.Name = "btnStrat";
this.btnStart.TabIndex = 4;
this.btnStart.Text = "启动";
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
//btnExit
//
this.btnExit.Location = new System.Drawing.Point(232, 64);
this.btnExit.Name = "btnExit";
this.btnExit.TabIndex = 5;
this.btnExit.Text = "退出";
//
//CurUserList
//
this.CurUserList.Location = new System.Drawing.Point(112.96);
this.CurUserList.Name = "CurUserList";
this.CurUserList.Size = new System.Drawing.Size(121, 20);
this.CurUserList.TabIndex = 6;
//
//label3
//
this.label3.Location = new System.Drawing.Point(8, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(96, 23);
this.label3.TabIndex = 8;
this.label3.Text = "当前在线用户:";
//
//lstInfo
//
this.lstInfo.ItemHeight = 12;
this.lstInfo.Location = new System.Drawing.Point(0, 128);
this.lstInfo.Name = "lstInfo";
this.lstInfo.Size = new System.Drawing.Size(304, 136);
this.lstInfo.TabIndex = 9;
//
//Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(312, 273);
this.Controls.Add(this.lstInfo);
this.Controls.Add(this.label3);
this.Controls.Add(this.CurUserList);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.txtPort);
this.Controls.Add(this.txtHost);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "ChatServer";
this.ResumeLayout(false);
}
#endregion
///<summary>
///The main entry point for the application.
///</summary>
[STAThread]
static void Main()
{
Application.Run(new ClientServerForm());
}
}
}