Download it here:
vrijdag, maart 02, 2007
Before reading this post:
- Read about workflows and its replicator activity.
- ECM Starter Kit and Workflow Development Starter Kit for WSS 3.0 RTM: many examples
When initializing a replicator you need to pass initiation data (like the foreach collection data). So if you want to pass a Contact for each replicated activity, you will set the initiationChildData (must implement IList) with Contact objects:
adding contacts like this: replicatorInitialChildData.Add(contact);
Sometimes you want the add your own classes to the List. You would except that this wouldn't be difficult, in fact it isn't:
Create the initiation data list with objects of your custom class:
IList replicatorInitialChildData = new List
/ fill the list with the ApproverFlow objects
The code will compile, the workflow will succeed sometimes (when the replicator is used in Parallel execution), sometimes not (when the replicator is used in Sequence execution), after a while you will notice this kind of errors:
(in the log folder in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS)
Workflow Infrastructure 72eo Unexpected DehydrateInstance: System.Runtime.Serialization.SerializationException: End of
Stream encountered before parsing was completed. at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck,
Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean
fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at
02/27/2007 14:50:31.00* w3wp.exe (0x0A98) 0x1700 Windows SharePoint Services Workflow Infrastructure
72eo Unexpected ... Activity outerActivity, IFormatter formatter) at
System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity) at
System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm(Byte activityBytes, Activity outerActivity)
at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId) at
System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor,
WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context,
WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId) at
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.InvalidOperationException: The platform does not know how to deserialize an object of type OfficialMail.Common.ApproverFlow+Approver. The platform can deserialize primitive types such as strings, integers, and GUIDs; other
SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in
one of these supported formats, or contact your software vendor for support.
You will notice the deserialize stuff.... If you think further, ..... whole the workflow idea is that every instance can be serialized or deserialized, because a workflow can wait for some other stuff, so objects will be saved somewhere (not in memory) when workflow is waiting.
When the replicator starts in parallel execution, no (de)serialize will occur because the workflow doens't need to serialize the objects, the replicator executes everything at once.
But when the replicator executes in sequence, it does need (de)serializing because the workflow will pause before executing the next step (so state is saved:(de)serializing occurs).
So when you want to add your own classes, keep in mind that your own class must be serializable.
Which types are serializable?
The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above.
In one of the next blog posts, I will explain how to add/change data when the replicator is already running ...