locked
'System.Data.DataRow' not marked as serializable

    Question

  • Hi,

     

    I am getting the following error when attempting to persist my work flow.

     

    Type 'System.Data.DataRow' in Assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.

     

    Any ideas?
    Monday, October 13, 2008 9:46 AM

All replies

  • I know that the DataRow object is not serializable and that this is the root cause of the error.

     

    My code is as follows:

    Code Snippet

    [Serializable]

    public partial class ApprovalGroupsRow : System.Data.DataRow {

    ...}

     

     

    If I remove the Serializable tag it complains that the ApprovalGroupsRow must be serializable...

     

     

     

    Monday, October 13, 2008 2:01 PM
  • A DataRow is not serializable, but a DataTable is. Use that as your field instead. The fact is you shouldn't be able to create a custom DataRow class without a custom DataTable class anyway because of methods used by the DataTable class to create new row objects.
    Monday, October 13, 2008 5:06 PM
  • Thank you for the comment. I am slightly confused as the code sample give above is generated code found in my .Designer.cs file of my DataSet. How can I make this change?

     

    Tuesday, October 14, 2008 7:45 AM
  • Do you need this data to be persisted?  If not mark it as NonSerialized.

     

    Thanks,

    Joel

     

    Thursday, October 30, 2008 5:22 PM
  • Had a similar problem today. Assuming that the data row is a private variable, then the workaround for this is to implement the ISerializable interface, add the _dataRow.Table object to the SerializationInfo object in the GetObjectData method as well as an int or string containing the id or composite key of the data row. Then create a constructor for the class used to deserialize the object, get the table and id back from the SerializationInfo and reset the private data row using the id and table.
    • Proposed as answer by Catster Friday, October 02, 2009 12:53 PM
    Friday, October 02, 2009 12:53 PM
  • Marked as helpful. In my case, the data did not need to be persisted.

    Tuesday, March 08, 2011 10:21 PM