C # Xml Deserializion Error

I am new to .net and xamarin. I am trying to develop a xamine form application. When I try to deserialize my xml, I accept the error.

Error Message is  

in System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0013d] in <6ae4606e5b2b46498c0e3768145.eml681451e1681681681681681.68168.68x68.70x1. XmlReflectionImporter.ImportTypeMapping (type System.Type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00048] at <6ae4606e5b2b46498c0ae37681c7e745>: 0 in System.Xml.Serialization.XS, type.XS. .Xml.Serialization.XmlAttributeOverrides overrides, System.Type [] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00041] to <6ae4606e5b2b46498c0ae37681c7e745X.serial..izer type System.Type) [0x00000] in <6ae4606e5b2b46498c0ae37681c7e745>: 0 in Fmkt44.icerik.Deserialize1 (System.String IasReturn) [0x00002] in C: \ Users \ TEKINHP \ source \ repos \ FimaksApp \ Fmkt44 \ Fmkt44 \ icerik.xam

[XmlRoot("REPORTLIST")]
[Serializable]
class REPORTLIST
{
    public REPORTLIST()
    {

    }       

    public List<ROW> ROW { get; set; }

}
[Serializable]
class ROW
{
    public ROW()
    {

    }
    public string INSTNUMBER { get; set; }
    public string MATERIAL { get; set; }

}

xml

 <REPORTLIST>
     <ROW>
        <MATERIAL>A</MATERIAL>
        <INSTNUMBER>B</INSTNUMBER>
    </ROW>
 </REPORTLIST>

My Deserialize

    public static Stream GenerateStreamFromString(string s)
    {
        MemoryStream stream = new MemoryStream();
        StreamWriter writer = new StreamWriter(stream);
        writer.Write(s);
        writer.Flush();
        stream.Position = 0;
        return stream;
    }
    REPORTLIST Deserialize1(String MyXml)
    {
      XmlSerializer serializer = new XmlSerializer(typeof(REPORTLIST));
      return (REPORTLIST)serializer.Deserialize(GenerateStreamFromString(MyXml));

    }

serializer.Deserialize

+4
1

:

REPORTLIST - . .

public. XmlSerializer internal. : [Serializable] - XmlSerializer. .

[XmlElement] , / .

:

[XmlRoot("REPORTLIST")]
public class ReportList
{
    [XmlElement("ROW")]
    public List<Row> Rows { get; } = new List<Row>();    
}
public class Row
{
    [XmlElement("INSTNUMBER")]
    public string InstNumber { get; set; }
    [XmlElement("MATERIAL")]
    public string Material { get; set; }
}
+3

Source: https://habr.com/ru/post/1691191/


All Articles