开发者

InvalidOperationException and Workflows in ASP.NET MVC

开发者 https://www.devze.com 2022-12-13 03:26 出处:网络
I\'m trying to query a running state machine workflow using StateMachineWrokflowInstance in ASP.NET MVC.

I'm trying to query a running state machine workflow using StateMachineWrokflowInstance in ASP.NET MVC.

Here is the scenario:

  1. Workflow runtime configuration: added SqlWorkflowPersistenceService, ManualWorkflowSchedulerService, ExternalDataExchangeService and registered custom ExternalDataExchange service with ExternalDataExchangeService;

  2. Execution sequence:

    var instance = WorkflowRuntimeHandle.CreateWorkflow(type);
    instance.Start();
    WorkflowRuntimeHandle.GetService<ManualWorkflowSchedulerService>
    ().RunWorkflow(instance.InstanceId);
    
    var stateMachineWorkflowInstance = new
    StateMachineWorkflowInstance(instance.WorkflowRuntime, instance.I开发者_如何学运维nstanceId); 
    
  3. Received error:

    System.InvalidOperationException: Workflow with id "[GUID]" not found in 
    state persistence store?
    

What am I doing wrong?


Apparently this exception could have many causes.

I found a way to detect the culprit. I added handlers for all the workflow runtime events and stored the sequence as history in a list and discovered from the list that after RunWorkflow is called the workflow was terminated.

The WorkflowTerminated event parameter WorkflowTerminatedEventArgs comes with a Exception property which includes inner exceptions that showed the real source of the problem.

I'm posting this here in hope that this experience would be beneficial to those who are reading.

0

精彩评论

暂无评论...
验证码 换一张
取 消