【问题标题】:asp.net and wf4 correlation exceptionasp.net 和 wf4 关联异常
【发布时间】:2012-01-03 13:02:40
【问题描述】:

我对 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 进行关联,该关联通过查询字符串传递到第三页。单击批准按钮会触发传入查询字符串值的服务的批准方法。它在这一点上我得到了例外。奇怪的是报错信息中的guid和im传入的值不一样

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

第一页

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

第三页

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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 2015-05-03
      • 2023-04-09
      • 2010-12-06
      相关资源
      最近更新 更多