2013-06-03 87 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

相關問題