我正在使用Visual Studio 2010的Beta 2版本开始学习使用WF4,并且遇到了持久性问题。在下面的代码中,如果我使用WorkflowApplication对象的注释掉的创建,持久性工作正常。如果我使用下面未注释的创建,我传递一个字典用于我想要传入的参数,那么持久性就会中断。任何想法为什么会这样,以及如何解决它?
List<Approver> approversRequired = new List<Approver>();
approversRequired.Add(new Approver("Dept Manager"));
approversRequired.Add(new Approver("Center Manager"));
Dictionary<String, Object> wfArguments = new Dictionary<string, object>();
wfArguments.Add("ApproversRequired", approversRequired);
//WorkflowApplication workflowApp = new WorkflowApplication(
// new WebCARSWorkflow());
WorkflowApplication workflowApp = new WorkflowApplication(
new WebCARSWorkflow(), wfArguments);
InstanceStore instanceStore = new SqlWorkflowInstanceStore(
@"Data Source=.\SQLEXPRESS;Integrated Security=True;Initial Catalog=WorkflowInstanceStore");
InstanceView view = instanceStore.Execute(
instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(),
TimeSpan.FromSeconds(30));
instanceStore.DefaultInstanceOwner = view.InstanceOwner;
workflowApp.InstanceStore = instanceStore;
workflowApp.PersistableIdle = (waie) => PersistableIdleAction.Unload;
workflowApp.Run();
WorkflowGuid.Text = workflowApp.Id.ToString();
workflowApp.ResumeBookmark("RequestSubmitted", "Submitted");
答案 0 :(得分:3)
您是否将审批者作为使用Serializable或DataContract属性修饰的参数传入?
您可以使用Aborted回调
查看persitence错误 workflowApp.Aborted = e => Console.WriteLine(e.Reason);