C # xml serializer - Cannot create temporary class
I am trying to serialize xml for a class like this:
XmlSerializer ser = new XmlSerializer(typeof(PSW5ns.PSW5)); StringReader stringReader; stringReader = new StringReader(response_xml); XmlTextReader xmlReader; xmlReader = new XmlTextReader(stringReader); PSW5ns.PSW5 obj; obj = (PSW5ns.PSW5)ser.Deserialize(xmlReader); xmlReader.Close(); stringReader.Close();
the PSW5 class is generated automatically by xsd.exe using the PSW5.xsd file provided to me. I have done the same for other classes and it works. Now I am getting the following error (at runtime):
{"Unable to generate a temporary class (result=1).\r\nerror CS0030:
Cannot convert type 'PSW5ns.TAX_INF[]' to 'PSW5ns.TAX_INF'\r\nerror CS0029:
Cannot implicitly convert type 'PSW5ns.TAX_INF' to 'PSW5ns.TAX_INF[]'\r\n"}
I am confused because it works the same for other classes. Any suggestions would be appreciated. Thanks in advance, Yorgos
a source to share
It looks like you are loading from an XML file that defines one member element (which is PSW5ns.TAX_INF
) with the same name as your class's array member (which is an array PSW5ns.TAX_INF[]
).
Are you sure you have serialized this particular class state in the XML document you are loading? If you change the class and try to load an old state that does not match the current schema, you might get errors like this.
a source to share