asp.net和wf4相关异常

时间:2012-01-03 13:02:40

标签: c# asp.net workflow-foundation-4

我对wf4很新,但创建了一个简单的控制台应用程序,提交,批准和拒绝功能就好了。我现在正在尝试创建一个asp.net应用程序,它消耗我已经创建的服务,但是我遇到了一个错误异常,如下所示。这在我的控制台应用程序中运行良好

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进行相关,通过查询字符串传递给第3页。单击批准按钮将触发传递查询字符串值的服务的批准方法。在这一点上,我得到了例外。奇怪的是错误消息中的guid与传入的值不一样。

以下任何想法都是我的代码有帮助

第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");
    }

第二页

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

1 个答案:

答案 0 :(得分:0)

该异常表示InstanceStore找不到与该密钥关联的工作流。可能是工作流已经完成或因错误而中止。您需要在WorkflowService上获取跟踪数据以查看出现了什么问题。见Troubleshooting Workflow Services with diagnostic logging