i writed the follow generic code to deserialize an XML file into a list:
public List<T> getList<T>(string fPath)
{
FileStream fs;
fs = new FileStream(fPath, FileMode.Open);
List<T> list;
XmlSerializer xmls = new XmlSerializer(typeof(List<T>));
list = (List<T>)xmls.Deserialize(fs);
fs.Close();
return list;
}
but i got the the Exception on the desirialize action.
"An exception of type
System.InvalidOperationException
occurred in System.Xml.dll but was not handled in user code"
this is an example for the XML file:
<?xml version="1.0"?>
<ArrayOfAdmin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Admin>
<MyUsername>User</MyUsername>
<MyPassword>Pass</MyPassword>
</Admin>
</ArrayOfAdmin>
whats cause the Exception?