خرید بک لینک

Vote count: 0

I have a problem. I have a student that is added to my list of students. When I call in main my SaveXml function and want save that list, everything is Ok. BUT. At the moment when I add some Subject to student´s list of subjects and want save my xml of students...there s call exception : An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll

Additional information: There was an error generating the XML document.

Here are my Student class and methods for save and load.

      public class Student : Person
      {
         public StudyProgramme Spec { get; set; }
         public Years ActualYear { get; set; }
         public List<Course> Schedule { get; set; }
         public List<Subject> Subjects { get; set; }
      }
      public class Database
      {
         public void SaveXML(List<Student> list)
         {
             XmlSerializer serializer = new XmlSerializer(list.GetType());
             using (TextWriter writer = new StreamWriter(@"Students.xml"))
            {
               serializer.Serialize(writer, list);
            }
         }

        public void LoadSaveXML()
        {
           using (var reader = XmlReader.Create(@"Students.xml"))
           {
              XmlSerializer deserializer = new XmlSerializer(typeof(List<Student>));
              dtbStudents = (List<Student>)deserializer.Deserialize(reader);
           }
        }
      }

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 30 خرداد 1395 ساعت: 20:31

صفحه بندی