WCF: generic list serialized to array

Posted by OpticalDelusion on Stack Overflow See other posts from Stack Overflow or by OpticalDelusion
Published on 2011-06-30T14:56:48Z Indexed on 2011/06/30 16:22 UTC
Read the original article Hit count: 271

Filed under:
|
|
|
|

So I am working with WCF and my services return types that contain generic lists. WCF is currently converting these to arrays over the wire. Is there a way I configure WCF to convert them back to lists afterwards? I know there is a way by clicking advanced when you add a service reference but I am looking for a solution in configuration files or something similar.

[DataContract(IsReference = true)]
public class SampleObject
{
  [DataMember]
  public long ID { get; private set; }

  [DataMember]
  public ICollection<AnotherObject> Objects { get; set; }
}

It is very odd, also, because one service returns it as a list and the other as an array and I am pretty sure they are configured identically.

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays