0

I have created a workflow in Visual Studio which contains a replicator which creates multiple tasks for approval. The replicator contains a sequence activity which is consisted of createTask, a while loop with onTaskChanged and a completeTask elements.

My workflow is behaving super strange. The replicator_Initialized properly initializes the InstanceData which is an IList of strings (i.e. the approvers), the replicator_ChildInitialized also behaves as expected, the createTask_MethodInvoking in the sequence activity executes fine and even the loop's isComplete method verifies for each of the tasks that they are not completed. But then, the onTaskChanged_Invoked never gets called and same goes for completeTask_MethodInvoking. In other words, I never get the chance to go to the workflow tasks list and approve the tasks. The workflow crashes and burns afterwards because I am trying to reference the tasks' AfterProperties which are all null of course because the after never happened.

Has anyone encountered anything similar? How do I fix or even analyze this? For example, I have no idea where to put the break point because it appears that the workflow just skips some parts. Thanks for all the help, I really appreciate it.

1 Answer 1

0

I solved this. The problem was that I have defined some fields in the Workflow1.cs file that were of type SPListItem, SPList and SPUser. When the tasks were created, the workflow crashed and to me it appeared that it just went through without creating tasks or waiting for them to be completed. Removing those particular fields from Workflow1.cs made everything work as expected.

I concluded that Workflow1.cs won't tolerate fields that are not of the following types:

  • int
  • bool
  • float
  • double
  • string
  • DateTime

Maybe it would if I added a field and made it serializable (or the whole Workflow1.cs, not sure).

1
  • Your guess is right. Workflow properties must be serialisable. In fact, the workflow runtime won't keep isntances in memory, but dehydrate and rehydrate the workflow class. In other terms, the workflow instance is serialized and deserialized from/to the db. I use to create a custom class "WorkflowContext", serializable, that I use to store all my workflow values, and bound the activities properties directly to this class (which can be actually a full object graph, as soon it's serializable)
    – Steve B
    Nov 29, 2012 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.