Reputation: 4144
I am trying to deserialize XML, but I receive this error:
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'responseReturnSalesOrder[]' to 'responseReturnSalesOrder'
error CS0029: Cannot implicitly convert type 'responseReturnSalesOrder' to 'responseReturnSalesOrder[]'
My xml contains an element called and it appears I cannot parse it.
XML is here:
Proxy class is here:
I found some weird code:
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute("salesOrder", typeof(responseReturnSalesOrder), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
public responseReturnSalesOrder[][] @return {
get {
return this.returnField;
}
set {
this.returnField = value;
}
}
Here is my code:
StringReader _InXml = new StringReader(responseData);
XmlSerializer _oxs = new XmlSerializer(typeof(response));
response _Response = new response();
_Response = (response)_oxs.Deserialize(_InXml);
Upvotes: 4
Views: 1287
Reputation: 15924
The issue is that public responseReturnSalesOrder[][]
should not be a multi dimensional array.
Change it to public responseReturnSalesOrder[]
and it should work. I find this issue happens when creating mapping files using xsd.exe from XML / XSD's.
Upvotes: 5