Click here to Skip to main content
15,177,127 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
given the following code 
    public class check
        public check()
            //int_array = new List<int>();
            string_array = new List<string>();

        public List<string> string_array;

        //public List<int> int_array;
        public void write_to_xml(string path)
            XmlSerializer serailizer = new XmlSerializer(typeof(check));
            TextWriter writer = new StreamWriter(path);
            serailizer.Serialize(writer, this);
        static void Main()
           //check class
            check c = new check();
            c.string_array.AddRange(new string[] { "string1", "string2", "string3" });

this code run OK and XML file generated is
<?xml version="1.0" encoding="utf-8"?>
<check xmlns:xsi="" xmlns:xsd="">

now remove comments in previous class and hit F5 again
what happen
this error appear There was an error reflecting type 'FET.check'.
Why this error appear?
IS serialized class must contain only one instance of XmlArray attribute ? or what?

1 solution

Hello Ibrahim,

Just change the annotations on int List as shown below.
[XmlArray("int_array", Order=2)]
[XmlArrayItem("int_element", typeof(int))]
public List<int> int_array;</int>

ibrahim ragab 24-Mar-13 10:12am
Thanks very much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900