Search code examples
c#wcfcollectionsdatacontract

WCF DataContract with collection property


WHY this does not work for the ContactData[] array property !? the received array is always empty!!!

WCF can serialize ContactData whithout any problem, but not a simple array of ContactData !?!? this is crazy o_O

What is the simplest and fastest way to send correctly this collection of ContactData through a wcf call ??

[DataContract]
public class MessageData
{       
    [DataMember]
    public ContactData From { get; set; }

    [DataMember]
    public ContactData[] To { get; set; }

    [DataMember]
    public string MessageText { get; set; }
}

[DataContract]
public class ContactData
{
    [DataMember]
    public string Name { get; set; }

    [DataMember]
    public string Address { get; set; }
}

Solution

  • It turned out to be my service reference that was not up to date, i deleted and recreated the service reference and it just worked fine, sorry for my stupidity...

    I misunderstood something I had read about serialization of collections and thought there was something different to do here.