我需要将一些简单的数据写入数据集www.example.com Web服务中已经存在的表中using.net,但是它给了我以下错误。
System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at System.Web.Services.Protocols.ServerProtocol.CreateServerInstance()
at System.Web.Services.Protocols.WebServiceHandler.Invoke()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
下面是我尝试过的代码。
public class DataSave : System.Web.Services.WebService
{
DataSet DS = new DataSet();
DataSet _dataset;
public DataSave(DataSet dataSet)
{
_dataset = dataSet;
}
[WebMethod]
public void SubmitStudents()
{
DataSet.StudentsRow row = _dataset.Students.NewStudentsRow();
row.Name = "Sam";
row.Age = 5;
row.School = "PreSchool";
row.Date = DateTime.Today;
this._dataset.Students.Rows.Add(row);
}
}
}
是什么原因导致此错误?
1条答案
按热度按时间gopyfrb31#
请尝试以下操作: