Providing array or list of class objects via WCF

冷暖自知 提交于 2019-12-02 01:38:50

It seems to me, that fault reason is here: abstract public class NFS.
The first, consider using of data contracts with WCF:

[DataContract(IsReference = true)]
abstract public class NFS : INFS 
{
  [DataMember]
  abstract public string Path { get; set; }

  // the rest of code here
}

The second, specify known types for your data contract. Serializers on both side of a communication channel have to know, how to seralize/deserialize concrete NFS' descendant type:

[DataContract(IsReference = true)]
[KnownType(typeof(NFS1))]
[KnownType(typeof(NFS2))]
abstract public class NFS : INFS 
{
  [DataMember]
  abstract public string Path { get; set; }

  // the rest of code here
}

public class NFS1 : NFS {}
public class NFS2 : NFS {}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!