Joseph Anderson
Joseph Anderson

Reputation: 4144

XML Serialization Error

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:

http://pastebin.com/3HD15Syv

Proxy class is here:

http://pastebin.com/M8HP7k9s

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

Answers (1)

webnoob
webnoob

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

Related Questions