private static void Main(string[] args) { TestDBConnection Do1 = new TestDBConnection { DBName = "SQLDB" }; PingTest Do2 = new PingTest { ServerName = "AccTestServ_5" }; ListOfToDo allTest = new ListOfToDo { Do1, (Do2) }; // Now I want to serialize my list. // Its here where I get the error at allTest XmlSerializer x = new XmlSerializer(allTest.GetType()); StreamWriter writer = new StreamWriter("mySerializedTestSuite.xml"); x.Serialize(writer, allTest); writer.Flush(); writer.Close(); //Read it aka deserialize { var xmlSerializer = new XmlSerializer(typeof(ListOfToDo)); var xmlReader = XmlReader.Create(new StreamReader("mySerializedTestSuite.xml")); ListOfToDo readWhatToTest = (ListOfToDo)xmlSerializer.Deserialize(xmlReader); xmlReader.Close(); } }
private static void Main(string[] args) { TestDBConnection Do1 = new TestDBConnection { DBName = "SQLDB" }; PingTest Do2 = new PingTest { ServerName = "AccTestServ_5" }; ListOfToDo allTest = new ListOfToDo { Do1, (Do2) }; // Now I want to serialize my list. // Its here where I get the error at allTest XmlSerializer x = new XmlSerializer(allTest.GetType()); StreamWriter writer = new StreamWriter("mySerializedTestSuite.xml"); x.Serialize(writer, allTest); }