Quantcast
Channel: TechNet Blogs
Viewing all articles
Browse latest Browse all 36188

Solving an error while deserialization of XML

$
0
0

If you face an error deserializing an XML like mentioned below

System.InvalidOperationException: There is an error in XML document (2, 2). ---> System.InvalidOperationException: <XmlRootElement xmlns=''> was not expected.
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderList1.Read3_ArrayOfXmlRootElement()

chances are that the name XmlRootElement is different from what you have set in your class which uses this XML to populate different XmlAttribute and XmlElement data in its variables.

If you have an XSD, you can auto-generate this class. If not, try setting the name of class same as XmlRootElement and set XmlRoot("XmlRootElement")] on top of class declaration.

 


 


Viewing all articles
Browse latest Browse all 36188

Trending Articles