I wonder why a class
can not do serialization
without empty constructor.
I tried it a few times when I got this error message:
ClassName cannot be serialized because it does not have a parameterless constructor.
The code goes like this:
public void DoSerialize(string path)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(List<MyClass>));
TextWriter textWriter = new StreamWriter(path);
serializer.Serialize(textWriter, MyList);
textWriter.Close();
}
catch (Exception e)
{
}
}
Really, when I added an empty constructor it worked