I wouldnt ask but i have no idea whats wrong again. Iv saved vehicles to an xml file and when the user opens the program i want to deserialize.when i run it i get this on the final line in the load method
'System.Windows.Markup.XamlParseException' {"'The invocation of the constructor on type 'SD2CW2.MainWindow' that matches the specified binding constraints threw an exception.'}
these are my load/save methods
private void Load()
{
XmlSerializer SerializerObj = new XmlSerializer(typeof(Vechicle));
// Reading a file requires a FileStream.
FileStream fs = new FileStream(filepath);
Vechicle = ((List<Vechicle>)SerializerObj.Deserialize(fs));
}
//Save the objects
private void Save()
{
// Create a new file stream to write the serialized object to a file
TextWriter WriteFileStream = new StreamWriter(filepath);
Type [] extraTypes= new Type[2];
extraTypes[0] = typeof(Tour);
extraTypes[1] = typeof(Vechicle);
// Create a new XmlSerializer instance with the type of List<Journey> and my addition types
XmlSerializer SerializerObj = new XmlSerializer(typeof(List<Journey>),extraTypes);
//serialising my journey list
SerializerObj.Serialize(WriteFileStream,Journey);
SerializerObj = new XmlSerializer(typeof(List<Vechicle>));
//serialising my vechicle list
SerializerObj.Serialize(WriteFileStream, Vechicle);
// Cleanup
WriteFileStream.Close();
}
this xml
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfJourney xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /><?xml version="1.0" encoding="utf-8"?>
<ArrayOfVechicle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Vechicle>
<Id>1</Id>
<Registration>1</Registration>
</Vechicle>
<Vechicle>
<Id>2</Id>
<Registration>2</Registration>
</Vechicle>
<Vechicle>
<Id>3</Id>
<Registration>3</Registration>