同じコードが 1 つのプロジェクトで機能し、他のプロジェクトでは機能しません。これを書く他の方法。エラー CS1729: 'Assessment' には、12 個の引数を取るコンストラクターが含まれていません。同じように、diff プロジェクトにコピーすると、コンパイルしてうまく動作します。一時的なasp.netファイルをクリーニングしようとしましたが、役に立ちません。
public class Assessment
{
public Assessment(Guid assessmentId,string applicationId,string assessmentType, Guid requestedBy,DateTime requestedDate,Guid assessmentOwner,string applicationToTest,
bool isCompleted,DateTime dateScheduled,DateTime datePerformed, GuidperformedBy, string uri)
{
this.AssessmentId = assessmentId; this.ApplicationId = applicationId;
this.AssessmentType = assessmentType; this.RequestedBy = requestedBy;
this.RequestedDate = requestedDate; this.AssessmentOwner = assessmentOwner;
this.ApplicationToTest = applicationToTest; this.IsCompleted = isCompleted;
this.DateScheduled = dateScheduled; this.DatePerformed = datePerformed;
this.PerformedBy = performedBy; this.uri = uri;
}
public Assessment()
{
this.AssessmentId = Guid.NewGuid(); this.ApplicationId = string.Empty;
this.AssessmentType = string.Empty; this.RequestedBy = Guid.NewGuid();
this.RequestedDate = DateTime.Now; this.AssessmentOwner = Guid.NewGuid();
this.ApplicationToTest = string.Empty; this.IsCompleted = false;
this.DateScheduled = Convert.ToDateTime(DateScheduled);
this.DatePerformed = Convert.ToDateTime(DatePerformed);
this.PerformedBy = Guid.NewGuid(); this.uri = string.Empty;
}
public Guid AssessmentId { get; set; }
public string ApplicationId {get; set; }
public string AssessmentType {get; set; }
public Guid RequestedBy { get; set; }
public DateTime RequestedDate {get; set; }
public Guid AssessmentOwner {get; set; }
public string ApplicationToTest {get; set; }
public bool IsCompleted { get; set; }
public DateTime DateScheduled {get; set; }
public DateTime DatePerformed { get; set; }
public Guid PerformedBy { get; set; }
public string uri { get; set; }
}
aspx.cs
protected void bnSubmit_Click(object sender, EventArgs e)
{
Assessment asst = new Assessment(Guid.Parse(AssessmentId.Text),
txtApplicationID.Text,
DropDownList1.SelectedValue,
requestedBy,
DateTime.Now,
Guid.Parse(txtAssessmentOwnerEmail.Text),
ddlApplicationToTest.SelectedValue,
false,
CalendarExtender1.SelectedDate.GetValueOrDefault(),
CalendarExtender2.SelectedDate.GetValueOrDefault(),
Guid.Parse(txtPerfomedBy.Text),
txtUri.Text);
db.AddAssessment(asst);
}