locked
Serialization at Persistence - InvokeMethod vs CodeActivity RRS feed

  • Question

  • I've created two workflows - one uses InvokeMethod activities extensively, whereas the other uses only custom CodeActivitys.

    I've noticed that when I try to persist the workflow containing the InvokeMethod activities, I have to modify my code to decorate it with [DataContract] and [DataMember] for serialization. However, when I wish to persist the workflow containing only CodeActivities, I do not have to make any changes.

    Is this just coincidence, or do CodeActivities always serialize without coding effort?

    Tuesday, April 5, 2011 3:39 PM

Answers

  • Hi jimasp,
    I don't think it's purely coincidence. Probably the difference is due to the difference in the set of properties on the two activities. For example, InvokeMethod activity has these properties and arguments which likely have no corresponding property on your CodeActivity:

    public Collection<Type> GenericTypeArguments { get; }
    public string MethodName { get; set;}
    public Type TargetType { get; set; }

    Consider also InvokeMethod.Parameters.

    for InvokeMethod it has Collection<InArgument> (that's InArgument with no <T>), and in order to serialize/deserialize the collection it needs to include sufficient information to disambiguate the types of the serialized objects in the collection, i.e. it has to serialize the type info 'what (T)' everywhere.

    For your type, firstly the types are probably unambiguous because you specified them as InArgument<int>, InArgument<string>, InArgument<MyType> explicitly.
    Secondly there's another possibility which is taht you are not using InArgument<T> at all, and you are just using plain T. In which case you're also serializing a different object.
    Tim

    • Marked as answer by Andrew_Zhu Tuesday, April 12, 2011 3:46 AM
    Wednesday, April 6, 2011 9:35 PM