Non-serializable data RRS feed

  • Question

  • My assumption is that all arguments (regardless of direction) and variables need to be serializable so that they can be persisted if necessary.  That was the assumption in the 3.x world -- is that still correct?

    If you do have non-serializable arguments or variables that you don't need to persist, is placing the [NonSerialized] attribute on them the way to go?  Or is there a different way to handle this now?

    Finally, if the [NonSerialized] attribute is the way to go, how to you go about doing that from the designer (or in Xaml)?

    Bruce Bukovics http://www.learnworkflow.com
    Friday, July 17, 2009 12:32 AM


  • Thanks for the question Bruce. 

    If you are using persistence and you have a variable or argument of a non-serializable type in 4.0 it needs to be placed in a no- persist zone.  There is a sample demonstrating this here: http://msdn.microsoft.com/en-us/library/dd807512(VS.100).aspx.  If the type you are using is serializable, but some of its fields doesn't need to be serialized you can use [NonSerialized] to avoid serializing the field.  Alternatively, you can use the DataContract programming model for determining which members are / are not serializable.

    Ed - MSFT
    Friday, July 17, 2009 11:55 PM