Cannot convert type data[] to data or data to data[] C#

by November 16, 2015 0 comments
This day I encounter a problem when working with web service SOAP. Something like this:
Cannot convert type 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem[]' to 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem'\r\nerror CS0030: Cannot convert type 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem[]' to 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem'\r\nerror CS0029: Cannot implicitly convert type 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem' to 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem[]'\r\nerror CS0029: Cannot implicitly convert type 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem' to 'SFDCSOAP.WebReference3rd.QuickActionLayoutItem[]'
The error is triggered when you try to create an instance of a XmlSerializer with a parameter type of a class generated from an xsd with xsd.exe. It's a bug of xsd.exe. The way I solved this problem is modifying the refrences.cs of that service from
[System.Xml.Serialization.XmlArrayItemAttribute("quickActionLayoutItems", typeof(QuickActionLayoutItem), IsNullable=false)]

    public QuickActionLayoutItem[][] quickActionLayoutColumns {
}
To
 [System.Xml.Serialization.XmlArrayItemAttribute("quickActionLayoutItems", typeof(QuickActionLayoutItem[]), IsNullable=false)]

    public QuickActionLayoutItem[][] quickActionLayoutColumns {
}

Because of this
private QuickActionLayoutItem[][] quickActionLayoutColumnsField;
Happy coding! :)

An Nguyen

Developer

Sharing daily exciting lesson learned and posts about .NET, SQL Server, HTML, Javascript - jQuery, CSS - Bootstrap, SalesForce CRM, Kentico CMS and so on.

0 comments :

Post a Comment