[ServiceContract]
[ServiceKnownType(typeof(DBReq))]
public interface IDAService
{
[DataContract]
[KnownType(typeof(IDataParameterCollection))]
public class DBReq : DBAccess
{
[DataMember]
public IDataParameterCollection DataParams
{
...
为什么DataParams在我的客户端反序列化为Object类型?
答案 0 :(得分:1)
您的[KnownType(typeof(IDataParameterCollection))]
不正确。您应该将实现类型传递给KnownType属性。
例如
public class MyType : IDataParameterCollection {...}
[DataContract]
[KnownType(typeof(MyType))]
public class DBReq : DBAccess
{
[DataMember]
public IDataParameterCollection DataParams
{
...