I know it's a pretty stupid question, but I'm stuck... (similar question with no useful answer here)
my xml is
<Param>
<MyList>
<mynode>aaa</mynode>
<mynode>bbb</mynode>
<mynode>ccc</mynode>
<mynode>ddd</mynode>
</MyList>
</Param>
and I have a class like this
public class MyClass
{
[XmlArray("MyList")]
[XmlArrayItem("mynode")]
public List<string> MyList { get; set; }
}
but when i try to deserialize i get a nullerrorexception
why this doesn't work?
edit: deserialize code:
public static Param InitConfig(string Path)
{
XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = "Param";
xRoot.IsNullable = true;
XmlSerializer serializer = new XmlSerializer(typeof(Param), xRoot);
using (StreamReader reader = new StreamReader(Path))
{
return (Param)serializer.Deserialize(reader);
}
}
and
public class Param
{
public MyClass MyClass {get; set;}
}
(actually more complex)