I'm trying to load a XML file from the storage like this:
var serializer = new XmlSerializer(typeof(AppModel));
var txt = File.ReadAllText(path);
if (txt.Length > 0)
{
using (var stringReader = new StringReader(txt))
{
var ret = (AppModel)serializer.Deserialize(stringReader);
return ret;
}
}
On Windows everything works fine, but on Android an exception is thrown:
System.InvalidOperationException: 'There is an error in XML document (0, 0). Inner Exception: Root element is missing.
But I set my RootElement and as said, this works on Windows, also the string is loaded correctly:
[Serializable]
[XmlRoot("AppModel")]
public class AppModel
{
//...
}
Am I missing something?