If you ever run into this XmlSerializer error: it's thrown because the name of the class being deserialized and the root node are not the same.
For example, if you're deserializing XML that looks something like this...
For example, if you're deserializing XML that looks something like this...
...into a class called...<PersonData>
<FirstName>Bob</FirstName>
<LastName>Black</LastName>
</PersonData>
...you'll get this error.
public class PersonDataXml
{
...
}
To resolve, just add the XmlRootAttribute to your class, thusly...
[XmlRoot( "PersonData" )]
public class PersonDataXml
{
...
}
Now XmlSerializer won't get all confused.