WCF: Serializing and Deserializing generic collections

后端 未结 4 1307
青春惊慌失措
青春惊慌失措 2020-12-10 01:25

I have a class Team that holds a generic list:

[DataContract(Name = \"TeamDTO\", IsReference = true)]
public class Team
{
    [DataMember]
    private IList&         


        
4条回答
  •  遥遥无期
    2020-12-10 02:11

    It sounds like your WCF service reference is creating a proxy class rather than using the existing type. Proxy classes can only use simple arrays and not any .NET specific types like the generic List.

    To avoid this proxy class conversion, in the Add Service Reference screen, click the Advanced button, and then make sure "Reuse types in referenced assemblies" is checked. This will ensure that the existing class (with the generic List) is used when serializing and deserializing the object.

提交回复
热议问题