WCF Client Side List <>

I have a WCF service with a method (GetUserSoftware) to send a list to a client.

software that I defined as follows:

[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 goes through my db to get all the software available for clien and generates a list to send back to the client.

Problem

is that I'm on the client side the list turns into an array. and every element in this array does not contain any attributes of my software.

I am debugging my way through the server. and it’s clear that the list he is about to send is correct. with the expected software and attributes in it.

Does anyone know how to get around this or know what I can do?

+3
5

[DataMemeber] ?

+4

DataContract , DataMember , . . , → , , .

+4

-, , , [DataMember]:

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

-, , .

+1

clien : "" , .

0
source

I had the same problem and now I solved it! This was a ServiceKnownType issue. If you have a well-known type loader, we must add a runtime type, for example:

Type aaa =  Type.GetType("System.Collections.Generic.List`1[[ProjectName.BusinessObjects.Bank, ProjectName.BusinessObjects, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null]]");

knownTypes.Add(aaa);

Anyone having the same problem can try this. He works in my environment!

0
source

Source: https://habr.com/ru/post/1784749/


All Articles