Quantcast
Viewing all articles
Browse latest Browse all 36188

Solving an error while deserialization of XML

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.

 


 

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 36188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>