I have a List<Object>
which I am trying to serialize using the XmlSerializer
and save to the disk but this piece of code generates an error while trying to serialize the file.
According to the thrown error message I get, I don't see anything wrong here and I think I need an extra pair of eyes on this.
Does anyone have a good idea as to why this keeps me awake all night? :/
I know the list contains the element so there is something going wrong with the types perhaps? Tried Type[]
but it gives the same problem.
public static void createFileXml(String path)
{
//This creates an error while serializing
XmlSerializer xmlser = new XmlSerializer(typeof(List<Object>));
TextWriter txtwrt = new StreamWriter(path);
try
{
xmlser.Serialize(txtwrt, lstCopy);
}
catch
{
throw;
}
finally
{
if (txtwrt != null)
{
txtwrt.Close();
}
}
}