2013-06-03 133 views
1

相同的代码在1 proj中工作,而不在其他中。任何其他方式来写这个。 我收到的错误是错误CS1729:'评估'不包含带12个参数的构造函数。同样,当我复制到一个差异proj它编译和运作良好。试图清理临时的asp.net文件,但没有帮助。错误cs1729不包含构造函数

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); 
    } 
+0

继续并添加缺少的'}',看看会发生什么。 – Hogan

+0

抱歉在哪里}缺失。那个在设置后关闭。我dint发布,因为它会很长 – user2340141

+0

代码是好的,所以尝试重新启动你的VS. – aef

回答

0

发布的代码显示Assessment类的开始。该班没有关闭}

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

所以我的猜测是这是两个文件,你加入部分来解释你的问题。这意味着您没有在页面类中包含使用情况 - 或者在名称中包含错字或正在引用项目中的其他文件。

评估类也可能不编译,但有一个预先编译的版本正在被链接到。

沿着这些线的东西。无论如何,这不是你正在使用的确切代码,所以我们不可能找出问题所在。你可以在某处填充完整的代码(bitbucket?),然后我们可以看到问题所在。

+0

有一个闭幕}。编辑的代码。请检查。我也怀疑评估类正在使用之前的编译版本。但我试图重建几次。我找不到干净的选项。 – user2340141

+0

@ user2340141 ...现在它有13个参数,这将与错误消息一致。 – Hogan

+0

对不起,我只看到12.你能指出哪里13? – user2340141

1

观光考虑:

  1. 是否有其他的命名空间命名为Assessment任何其它类的定义?
  2. 检查您的项目参考。确保您引用的程序集包含正确的Assessment定义。你可能会在不知不觉中引用该程序集的旧版本。
  3. 使用像ILSpy这样的反汇编程序来检查包含Assessment的程序集。确认它包含正确的类定义。
+0

这很有用。谢谢!! – ElSS

相关问题