Windows Phone 7 isolated storage serialization errors with List of objects -


i have been trying serialize list of objects class , keep getting error stating there error in xml file @ point (25, 6)(these numbers change depending on trying serialize).

here's example of how trying serialize data:

 using (isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication()) {     using((isolatedstoragefilestream fs = isf.createfile("data.dat"))     {         xmlserializer ser = new xmlserializer(user.data.gettype());         ser.serialize(fs, user.data);
} }

, here's how deserializing data:
 using (isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication()) {     if (isf.fileexists("data.dat"))     {         using (isolatedstoragefilestream fs = isf.openfile("data.dat", system.io.filemode.open))         {             xmlserializer ser = new xmlserializer(user.data.gettype());             object obj = ser.deserialize(fs);             if (null != obj && obj data)                 user.data= obj data;         }     } } 

don't see initial problems portion of code, crashes on every list of objects pass it.

here's sample of class i'm using:

 public class data     {         public static int counter;          public data() { this.index = counter++; }          public datetime availablefrom { get; set; }         public datetime availableuntil { get; set; }         public string course { get; set; }         public datetime? datetaken { get; set; }         public double duration { get; set; }         public string instructions { get; set; }         public string instructorname { get; set; }         public double scorepointscorrect { get; set; }         public double scorepointspossible { get; set; }         public string testname { get; set; }         public int index { get; private set; }     } 

when give serializer simple classes works, know serializer working, when create list of objects data class or other classes, crashes. have suggestions?

since "index" public property of data, deserializer trying set value of it. fails because set "index" private. try setting "index" internal instead of public , should deserialize correctly.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -