我试着去创建一个Web服务,需要一些论据在其构造,以节省往返,但我不断收到错误: CS1729“服务名”不包含一个构造函数“1”的论点Webservice C#构造函数不允许参数?
虽然当我尝试在本地创建即时(在与服务相同的项目中),一切正常......什么给予了?
web服务:
public class ayyash : System.Web.Services.WebService {
private string _myname;
public ayyash (string myname) {
_myname = myname;
//Uncomment the following line if using designed components
//InitializeComponent();
}
}
消耗:
ayyash a = new ayyash("my name is ayyash");
输出:
Compiler Error Message: CS1729: 'ayyash' does not contain a constructor that takes '1' arguments
我还没有测试,但作为WebMethod公开的构造函数? – 2009-08-24 02:39:02
你不能公开构造函数作为webmothod – Ayyash 2009-08-24 03:19:33