locked
using LINQ objects in workflows RRS feed

  • Question

  • I have recently upgraded my entity objects from framework 2.0 to framework 3.5 using sqlmetal to utilize LINQ in application.  When this new entity object is passed to my workflow it terminates while persisting the workflow to database with the following error:

     

    Type 'System.Data.Linq.ChangeTracker+StandardChangeTracker' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

     

    Clearly the runtime is unable to serialize the new entity object.  Is there some workaround for using the linq based entity object or is there some thing that I have missed? 

     

    I would appreciate all the suggestions to rectify this problem.

     

    Thanks

    Friday, February 8, 2008 7:20 AM

Answers

  • Hello, Farhan:

     

    What you reported is a general issue about .NET serialization and deserialization, which is largerly answered by classes related to the BinaryFormatter Class and  the SerializableAttribute Class

     

    Basically, if you want to persist a .NET object, the type of the object should be marked as Serializable. In your case, the class System.Data.Linq.ChangeTracker+StandardChangeTracker is not marked Serializable. Although I cannot confim immediately, this usually implies that an object of that class cannot be reconstituted in a different environment easily or correctly.

     

    You have two options:

     

    1. Mark your data field as NonSerialized. Then WF runtime will not try to persist that field.

    2. Create a surrogate class that binds to this class if you believe you can restore the persisted data meaningfully.

     

    For more detail, you can check the documentation related to those two classes I mentioned above.

    Monday, February 11, 2008 8:25 PM

All replies

  • Hello, Farhan:

     

    What you reported is a general issue about .NET serialization and deserialization, which is largerly answered by classes related to the BinaryFormatter Class and  the SerializableAttribute Class

     

    Basically, if you want to persist a .NET object, the type of the object should be marked as Serializable. In your case, the class System.Data.Linq.ChangeTracker+StandardChangeTracker is not marked Serializable. Although I cannot confim immediately, this usually implies that an object of that class cannot be reconstituted in a different environment easily or correctly.

     

    You have two options:

     

    1. Mark your data field as NonSerialized. Then WF runtime will not try to persist that field.

    2. Create a surrogate class that binds to this class if you believe you can restore the persisted data meaningfully.

     

    For more detail, you can check the documentation related to those two classes I mentioned above.

    Monday, February 11, 2008 8:25 PM
  • Hey Qiang,

     

    Thanks for your input.

     

    I am aware of the BinaryFormatter Class and  the SerializableAttribute Class.  The problem is my entity class generated through sqlmetal and it's base base class is marked as serializable. I cannot mark the class System.Data.Linq.ChangeTracker+StandardChangeTracker as serializable because it is some internal class of the framework which I cannot modify.

     

    Is this a framework issue or something I am not doing propertly?

    Wednesday, February 13, 2008 5:16 AM