Inherited Class using as datacontract
Actually I Have a Problem Using a Inherited Class as a DataContract. Below is My Code
[DataContract]
public class PartialTestClass
{
}
[DataContract]
public class TestClass : PartialTestClass
{
}
[ServiceContract(Name = "IMessageContract",
CallbackContract = typeof(IMessageCallback))]
public interface IMessageContract
{
[OperationContract]
开发者_如何学PythonPartialTestClass Test(PartialTestClass partialTestClass);
}
Client Side:
PartialTestClass p = new TestClass();
p.Name = "Afshin.Ahmari";
TestClass p2 = (TestClass)Proxy.Test(p);
Can Anybody help me with this
Child classes need to be known types of the base class:
[DataContract]
[KnownType(typeof(TestClass))]
public class PartialTestClass { }
精彩评论