A wordaround way for issue: CompositeActivity cannot transition to 'Closed' status when there are active child activity.

 BTW:不知道怎么上传zip文件,谁能指教一下?

Recently I add compensation feature for workflow process in our project, however I get a weird InvalidOperationException Exception:

‘CompositeActivity cannot transition to 'Closed' status when there are active child activity’. Btw internal call stack is

  at System.Workflow.ComponentModel.Activity.MarkClosed()

   at System.Workflow.ComponentModel.Activity.MarkFaulted()

   at System.Workflow.ComponentModel.ActivityExecutionContext.CloseActivity()

   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)

   at System.Workflow.Runtime.Scheduler.Run()

 

I take a long time to make a dig, and finally find out a workaround way to avoid the issue.

 

Repro scenario for this issue at attached ComposateIssue project: (My Environment: VS2008, and WF3.5/Workflow Service using ReceiveActivity)

The workflow is as follows:

  

 

The workflow waits the GetData event by ReceiveActivity; activityTestCompensate1 that is an instance of ActivityTestCompensate custom activity including ComponsatableSequenceActivity named cpsActivity1, for figure 1 you can see normal process of it, and for figure 2 you can see Fault handler process of it, comensateActivity1 is an instance of CompensateActivity.

The issue for that exception occurs when meeting both of two conditions:

  1. activityTestCompensate1 is placed inside ReceiveActivity.
  2. compensateActivity1 set TargetActivityName property to ActivityTestCompensate rather than cpsActivity1.

 

 Resolution:

That is so simple, if only we break any of two conditions above, that exception will disappear.

 

posted @ 2010-09-10 11:39  大料  阅读(944)  评论(0编辑  收藏  举报