2012-01-03 28 views
0

我很新的wf4,但創建了一個簡單的控制檯應用程序提交,批准和拒絕功能就好了。我現在正在嘗試創建一個消耗我創建的服務的asp.net應用程序,但正在收到如下所示的錯誤異常。這在我的控制檯應用程序運行良好asp.net和wf4相關異常

The execution of an InstancePersistenceCommand was interrupted because 
the instance key '3a552603-c92f-2424-085c-7b6fc1a0e98e' was not associated to 
an instance 

基本上香港專業教育學院創建了3個簡單的網頁。第一頁是用戶提交請求的簡單形式。第二頁僅打印請求列表。點擊其中一個請求,即可進入第3頁,該頁面通過批准和拒絕按鈕打印請求的更詳細視圖。我使用通過查詢字符串傳遞給第三頁的關聯GUID。點擊批准按鈕激發查詢字符串值中傳遞服務的批准方法。在這一點上,我得到了例外。奇怪的是在錯誤消息的GUID是不一樣的價值IM傳入。

以下任何想法是我的代碼是幫助

第1頁

protected void Unnamed1_Click(object sender, EventArgs e) { 
     ServiceReference1.ServiceClient Client = new ServiceReference1.ServiceClient(); 
     ServiceReference1.Request R = new ServiceReference1.Request(); 
     R.Title = TxtRequestTitle.Text; 
     R.Amount = Convert.ToInt32(TxtAmount.Text); 

     Guid g = Guid.NewGuid(); 

     Client.SubmitRequest(R, g); 

     Response.Write("submitted"); 
    } 

第2頁

protected void Page_Load(object sender, EventArgs e) { 
    using (SqlConnection con = new SqlConnection(@"Data Source=bantai11\sqlexpress;Initial Catalog=RequestMonkey;Integrated Security=True;Asynchronous Processing=True")) { 
     using (SqlCommand com = new SqlCommand()) { 
      com.Connection = con; 

      com.CommandType = System.Data.CommandType.Text; 
      com.CommandText = "Select InstanceId, Title, state from Requests"; 

      DataTable dt = new DataTable(); 
      SqlDataAdapter sda = new SqlDataAdapter(com); 
      sda.Fill(dt); 

      rp.DataSource = dt; 
      rp.DataBind(); 
     } 
    } 
} 

第3頁

protected void Page_Load(object sender, EventArgs e) { 
     this._id = Request.QueryString.Get("Id"); 

     using (SqlConnection con = new SqlConnection(@"Data Source=bantai11\sqlexpress;Initial Catalog=RequestMonkey;Integrated Security=True;Asynchronous Processing=True")) { 
      using (SqlCommand com = new SqlCommand()) { 
       con.Open(); 

       com.Connection = con; 

       com.CommandType = System.Data.CommandType.Text; 
       com.CommandText = "Select InstanceId, Title, state from Requests where instanceid = '" + this._id + "'"; 

       SqlDataReader dr = com.ExecuteReader(); 

       dr.Read(); 

       lblTitle.Text = dr[1].ToString(); 
       lblGuid.Text = dr[0].ToString(); 
       lblAmount.Text = "0"; 
      } 
     } 
} 

protected void btnApprove_Click(object sender, EventArgs e) { 
     ServiceReference1.ServiceClient Client = new ServiceReference1.ServiceClient(); 
     Client.Approve(1, this._id); 
    } 

回答