我用.net 的remoting 开发一个客户端和服务器端,当我调试服务器端的时候出现如下错误:
错误 1 程序“C:\Documents and Settings\liu\My Documents\Visual Studio 2008\Projects\YABS\YABS.Shared\obj\Debug\YABS.Shared.exe”不包含适合于入口点的静态“Main”方法.
请问是什么原因?
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
//using YABS.Shared;namespace YABS.Server
{
public class Server
{
public static void Main(string[] args)
{
Console.WriteLine("***Welcome***"); SoapServerFormatterSinkProvider serverProvider =
new SoapServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full; SoapClientFormatterSinkProvider clientProvider =
new SoapClientFormatterSinkProvider();
IDictionary properties = new Hashtable();
properties.Add("port", 6123);
HttpChannel chan = new HttpChannel(properties,clientProvider, serverProvider);
ChannelServices.RegisterChannel(chan,false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject),"yabs",WellKnownObjectMode.Singleton); Console.WriteLine("Server is started.");
} }
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting.Lifetime;namespace YABS.Server
{
public class RemoteObject : MarshalByRefObject,IRemoteObject
{
public void RemotObject()
{
Console.WriteLine("remote object is instanced");
} private class Article
{
public uint id = 0;
public string name = "";
public uint price= 0;
public string vendor = "";
public string description;
public string bider="";
public Article(uint id, string name, uint price, string vendor, string description,string bider)
{
this.id = id;
this.name = name;
this.price = price;
this.vendor = vendor;
this.description = description;
this.bider = bider; } public void setPrice(uint price)
{
this.price = price;
}
public uint getPrice()
{
return this.price;
}
}
List<Article> articles = new List<Article>(); public string regArticle(uint id, string name, uint price, string vendor, string description, string bider)
{
try
{
Console.WriteLine("Usage: id| name|price|vendor|description");
string str1 = Console.ReadLine();
string[] strArray = str1.Trim().Split('|');
id = uint.Parse(strArray[0]);
name = strArray[1];
price = uint.Parse(strArray[2]);
vendor = strArray[3];
description = strArray[4]; Article myArticle = new Article(id,name,price,vendor,description,bider);
articles.Add(myArticle);
return "OK";
}
catch
{
Console.WriteLine("Error: Offering an article FAILED");
return "FAILED";
} } public override object InitializeLifetimeService()
{
ILease lease = (ILease)base.InitializeLifetimeService();
if (lease.CurrentState== LeaseState.Initial)
{
lease.InitialLeaseTime= TimeSpan.FromMinutes(100);
lease.RenewOnCallTime= TimeSpan.FromMinutes(20);
}
return lease; //return null = Objektlebtso langewieProzess
}
//list current Bid and left duration
public string list()
{
string returnString = "";
try
{
foreach (Article myArticle in articles)
{
returnString += myArticle.id+"|"+myArticle.name + "|" + myArticle.price + "|" + myArticle.description + "|"+myArticle.description+"\r\n";
return returnString;
}
Console.WriteLine("FAILED");
return "FAILED";
}
catch
{
Console.WriteLine("Error: List all articles FAILED");
return "FAILED";
}
} public string getArticle(string name)
{
foreach (Article myArticle in articles)
{
if (name.Trim().Equals(myArticle.name.Trim().ToLower()))
{
return "ok";
}
}
Console.WriteLine("FAILED");
return "FAILED";
} public void Bid(uint id, uint price)
{
foreach(Article myArticle in articles)
{
if(id == myArticle.id)
{
if(price > myArticle.price )
{
myArticle.price = price;
Console.WriteLine("Biding Sucessful!");
break;
}
else
{
Console.WriteLine("Youre given price is too low!");
break;
}
}
else
{
Console.WriteLine("There is no associated article, please select again");
return;
} }
}
public string winnNotify(int id)
{
foreach(Article myArticle in articles)
{
if (id == myArticle.id)
{
return "Vendor: " + myArticle.vendor + ", Winner" + myArticle.bider + ", Price" + myArticle.price;
}
}
Console.WriteLine("FAILED");
return "FAILED"; }
}
}
错误 1 程序“C:\Documents and Settings\liu\My Documents\Visual Studio 2008\Projects\YABS\YABS.Shared\obj\Debug\YABS.Shared.exe”不包含适合于入口点的静态“Main”方法.
请问是什么原因?
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
//using YABS.Shared;namespace YABS.Server
{
public class Server
{
public static void Main(string[] args)
{
Console.WriteLine("***Welcome***"); SoapServerFormatterSinkProvider serverProvider =
new SoapServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full; SoapClientFormatterSinkProvider clientProvider =
new SoapClientFormatterSinkProvider();
IDictionary properties = new Hashtable();
properties.Add("port", 6123);
HttpChannel chan = new HttpChannel(properties,clientProvider, serverProvider);
ChannelServices.RegisterChannel(chan,false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObject),"yabs",WellKnownObjectMode.Singleton); Console.WriteLine("Server is started.");
} }
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting.Lifetime;namespace YABS.Server
{
public class RemoteObject : MarshalByRefObject,IRemoteObject
{
public void RemotObject()
{
Console.WriteLine("remote object is instanced");
} private class Article
{
public uint id = 0;
public string name = "";
public uint price= 0;
public string vendor = "";
public string description;
public string bider="";
public Article(uint id, string name, uint price, string vendor, string description,string bider)
{
this.id = id;
this.name = name;
this.price = price;
this.vendor = vendor;
this.description = description;
this.bider = bider; } public void setPrice(uint price)
{
this.price = price;
}
public uint getPrice()
{
return this.price;
}
}
List<Article> articles = new List<Article>(); public string regArticle(uint id, string name, uint price, string vendor, string description, string bider)
{
try
{
Console.WriteLine("Usage: id| name|price|vendor|description");
string str1 = Console.ReadLine();
string[] strArray = str1.Trim().Split('|');
id = uint.Parse(strArray[0]);
name = strArray[1];
price = uint.Parse(strArray[2]);
vendor = strArray[3];
description = strArray[4]; Article myArticle = new Article(id,name,price,vendor,description,bider);
articles.Add(myArticle);
return "OK";
}
catch
{
Console.WriteLine("Error: Offering an article FAILED");
return "FAILED";
} } public override object InitializeLifetimeService()
{
ILease lease = (ILease)base.InitializeLifetimeService();
if (lease.CurrentState== LeaseState.Initial)
{
lease.InitialLeaseTime= TimeSpan.FromMinutes(100);
lease.RenewOnCallTime= TimeSpan.FromMinutes(20);
}
return lease; //return null = Objektlebtso langewieProzess
}
//list current Bid and left duration
public string list()
{
string returnString = "";
try
{
foreach (Article myArticle in articles)
{
returnString += myArticle.id+"|"+myArticle.name + "|" + myArticle.price + "|" + myArticle.description + "|"+myArticle.description+"\r\n";
return returnString;
}
Console.WriteLine("FAILED");
return "FAILED";
}
catch
{
Console.WriteLine("Error: List all articles FAILED");
return "FAILED";
}
} public string getArticle(string name)
{
foreach (Article myArticle in articles)
{
if (name.Trim().Equals(myArticle.name.Trim().ToLower()))
{
return "ok";
}
}
Console.WriteLine("FAILED");
return "FAILED";
} public void Bid(uint id, uint price)
{
foreach(Article myArticle in articles)
{
if(id == myArticle.id)
{
if(price > myArticle.price )
{
myArticle.price = price;
Console.WriteLine("Biding Sucessful!");
break;
}
else
{
Console.WriteLine("Youre given price is too low!");
break;
}
}
else
{
Console.WriteLine("There is no associated article, please select again");
return;
} }
}
public string winnNotify(int id)
{
foreach(Article myArticle in articles)
{
if (id == myArticle.id)
{
return "Vendor: " + myArticle.vendor + ", Winner" + myArticle.bider + ", Price" + myArticle.price;
}
}
Console.WriteLine("FAILED");
return "FAILED"; }
}
}
解决方案 »
- 【提问-双缓冲】我有个自己不太确定的问题
- 一个题目
- 未能向文件“obj\Debug\ContactUI.csproj.FileListAbsolute.txt”写入命令行。
- 可不可以把GropBox控件的边框设置的明显点
- 哪里能下载关于vs2005的c# winform的书籍!!
- 怎么判断一个字符串内是否包含指定的字符串?
- 紧急求助:DataGrid单击的问题!!!
- 求PDF转换成高清图片,code
- VS.NET 中的C#,和VC.NET有没有办法设置成向VB那样,可以输入代码时不考虑大小写
- Socket如何连接腾讯云服务器 急!
- 怎样使窗体最小化时不显示在任务栏中?
- picturebox图片替换 数据库的存取
右键选择项目、属性、应用程序、启动对象下拉框
看看里面有东西没?如果是多个选一个
如果一个没有哪么可能你的代码中有,非标准字符;YABS.Shared.exe 就是你给的代码吗???
怪