Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF client side List<>

Tags:

wcf

I got a WCF service with a method (GetUserSoftware)to send a List to a client.

the software I have defined like this:

[DataContract]
public class Software
{
    public string SoftwareID { get; set; }
    public string SoftwareName { get; set; }
    public string DownloadPath { get; set; }
    public int PackageID { get; set; }

}

the method is going through my db to get all software availeble to the clien, and generates a list of that to send back to the client.

problem is i on the client side the list is turned into an array. and every item in that array dont contain any of my software attributs.

i have debugged my way through the server side. and seen that the list its about to send is correct. with the expected software and attributs in it.

any one know how to work around this or know what i can do ?

like image 701
MrKanin Avatar asked Dec 02 '25 08:12

MrKanin


2 Answers

Did you forget [DataMemeber] attribute on your properties?

like image 169
Aliostad Avatar answered Dec 04 '25 21:12

Aliostad


When you use DataContract attribute for a type you have to use DataMember attribute for each property or field you want to serialize and transfer between service and client. Collections are by default created as arrays. If you don't like it you can change this behavior in Add Service Reference window -> Advanced settings where you can select which collection type should be used.

like image 32
Ladislav Mrnka Avatar answered Dec 04 '25 21:12

Ladislav Mrnka