6

I tried today to generate a proxy with the entreprise.wsdl file (also tried with partner.wsdl) and noticed that the file was 'not valid'.

When generating the proxy, everything seems to be okay, but at runtime (I'm writing a client in C#, but this probably doesn't play any role) an exception is raised on this line:

SForceService service = new SForceService();

The error is:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll Additional information: Temporäre Klasse kann nicht generiert werden (result=1).

error CS0030: Eine Konvertierung vom Typ 'Entreprise.ListViewRecordColumn[]' in 'Entreprise.ListViewRecordColumn' ist nicht möglich.

error CS0030: Eine Konvertierung vom Typ 'Entreprise.ListViewRecordColumn[]' in 'Entreprise.ListViewRecordColumn' ist nicht möglich.

error CS0029: Eine implizite Konvertierung vom Typ 'Entreprise.ListViewRecordColumn' in 'Entreprise.ListViewRecordColumn[]' ist nicht möglich.

error CS0029: Eine implizite Konvertierung vom Typ 'Entreprise.ListViewRecordColumn' in 'Entreprise.ListViewRecordColumn[]' ist nicht möglich.

The translation in english should be something like this:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll. Additional information: A temporary class cannot be generated (result=1)

error CS0030: An implicit conversion from type "Entreprise.ListViewRecordColumn[]' to 'Entreprise.ListViewRecordColumn' is not possible.

error CS0030 : An implicit conversion from type 'Entreprise.ListViewRecordColumn[]' to 'Entreprise.ListViewRecordColumn' is not possible.

error CS0029: An implicit conversion from type 'Entreprise.ListViewRecordColumn' to 'Entreprise.ListViewRecordColumn[]' is not possible.

error CS0029: An implicit conversion from type 'Entreprise.ListViewRecordColumn' to 'Entreprise.ListViewRecordColumn[]' is not possible.

using an old wsdl file (downloaded from Salesforce last year) fixed the problem, but this is not a solution for me since I created a lot of new objects that are not in this old wsdl file...

Does anybody have the same problem? How to fix this?

  • I don't suppose you could provide the error messages in English somehow? – Alex Tennant Jul 14 '15 at 13:30
  • See my edited post for the english translation – Bidou Jul 14 '15 at 13:41
7

Looks like it could be a bug in .NET's XML serializer:

https://help.salesforce.com/HTViewSolution?id=000205824&language=en_US

  • 1
    I followed the instructions of the link you provided which basically says that one should replace all occurences of [][] with [] and....... it works! Excellent! thank you... – Bidou Jul 14 '15 at 13:57
1

Actually, it is a bug. It's due to the fact that the ListViewRecord object only has a single elements, "columns", which is a collection of ListViewRecordColumn objects. .NET reads the WSDL, but skips over making the ListViewRecord class entirely.

That's why you're seeing [][]... fixing it to [] makes it compile, but it's not "right". It should be ListViewRecord[].

So, to fix this, first open the Reference.cs which contains the C# that was auto-generated from then WSDL (assuming you're using Connected Services, instead of Web References, which was .NET-2-era). Around line 11883 (yikes!), I introduced the ListViewRecord class by hand. It looks like this

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.2102.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:enterprise.soap.sforce.com")]
    public partial class ListViewRecord : object, System.ComponentModel.INotifyPropertyChanged
    {

        private ListViewRecordColumn[] columnsField;

        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(IsNullable = true, Order = 1)]
        [System.Xml.Serialization.XmlArrayItemAttribute("records", typeof(ListViewRecordColumn), IsNullable=false)]
        public ListViewRecordColumn[] columns
        {
            get
            {
                return this.columnsField;
            }
            set
            {
                this.columnsField = value;
                this.RaisePropertyChanged("columns");
            }
        }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null))
            {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
    }

With that, I then went through and found all (3?) of the references to ListViewRecordColumn[][], and changed them to ListViewRecord[]. Essentially, preserving "the array of things that holds an array of ListViewRecordColumns" the idea by following the WSDL and putting that latter array behind a .columns property.

It is a shame that Microsoft isn't addressing this bug, because they never, ever will. It's also a shame that Salesforce had the gumption to introduce ListViewRecord when it only served as a thin/useless container for ListViewRecordColumns. Bug vs poor design? I dunno, but given Salesforce's track record with its partner WSDL (which isn't even valid), I can't lay blame solely at Microsoft's door.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.