The Problem
Each time I come to update the Enterprise WSDL from SalesForce on a project I'm working on it I hit this issue so am adding it to my blog for my own reference and in the hope that it might help someone else in the future.
The full error looks like this:
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn[]' to 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn'
error CS0030: Cannot convert type 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn[]' to 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn'
error CS0029: Cannot implicitly convert type 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn' to 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn[]'
error CS0029: Cannot implicitly convert type 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn' to 'MyNamespace.MyProject.SalesForceApi.ListViewRecordColumn[]'
The fix, which is particularly obvious, seems to be due to an issue with the XmlSerializer Code Generation component: it cannot handle some cases of nested unbounded elements.
Thankfully, once you are aware of the issue the fix is easy and quick and luckily the WSDL for this project is rarely updated so I've not had cause to look for a more permanent solution.
The Solution
Open the Reference.cs
file generated for you by the tooling when you added the web service reference and perform a find and replace on the file to locate and replace all instances of [][]
with []
. Rebuild your project and you should be good to go!
Here is an example of a couple of instances from my file:
private ListViewRecordColumn[][] recordsField;
[System.Xml.Serialization.XmlArrayItemAttribute("columns", typeof(ListViewRecordColumn), IsNullable=false)]
public ListViewRecordColumn[][] records {
get {
return this.recordsField;
}
set {
this.recordsField = value;
}
}
Which will become…
private ListViewRecordColumn[] recordsField;
[System.Xml.Serialization.XmlArrayItemAttribute("columns", typeof(ListViewRecordColumn), IsNullable=false)]
public ListViewRecordColumn[] records {
get {
return this.recordsField;
}
set {
this.recordsField = value;
}
}