实际上我使用继承类作为DataContract时遇到问题。以下是我的代码
[DataContract]
public class PartialTestClass
{
}
[DataContract]
public class TestClass : PartialTestClass
{
}
[ServiceContract(Name = "IMessageContract",
CallbackContract = typeof(IMessageCallback))]
public interface IMessageContract
{
[OperationContract]
PartialTestClass Test(PartialTestClass partialTestClass);
}
客户端:
PartialTestClass p = new TestClass();
p.Name = "Afshin.Ahmari";
TestClass p2 = (TestClass)Proxy.Test(p);
任何人都可以帮助我
答案 0 :(得分:0)
子类需要是基类的known types:
[DataContract]
[KnownType(typeof(TestClass))]
public class PartialTestClass { }