错误cs1729不包含构造函数

时间:2013-06-03 21:20:57

标签: c# constructor compiler-errors

相同的代码适用于1个项目而不是其他项目。写这个的任何其他方式。 我得到的错误是错误CS1729:'评估'不包含带有12个参数的构造函数。同样当我复制到diff proj时,它编译并运行良好。尝试清理临时的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);
  }

2 个答案:

答案 0 :(得分:2)

要研究的事项:

  1. 其他名称空间中是否还有其他名为Assessment的类定义?
  2. 检查您的项目参考。确保引用包含正确Assessment定义的程序集。您可能会在不知不觉中引用该程序集的旧版本。
  3. 使用反汇编程序(如ILSpy)检查包含Assessment的程序集。验证它包含正确的类定义。

答案 1 :(得分:0)

发布的代码显示了Assessment课程的开始。该课程没有结束}

然后有一个函数调用(通常是页面类的一部分),它创建一个新的Assessment类。

所以我的猜测是你加入了两个文件来解释你的问题。这意味着您没有在页面类中包含使用 - 或者名称中有拼写错误或者在项目中引用了不同的文件。

评估类也可能没有编译,但是有一个先前编译的版本正在链接。

这些方面的东西。在任何情况下,这都不是您使用的确切代码,因此我们无法确定问题所在。你可以在某个地方填写完整的代码(bitbucket?),然后我们可以看到问题所在。