As per MSDN KnownTypes Specifies known types to be used by a service when serializing or deserializing. I am trying to serialize using DataContractSerializer.
[KnownType(typeOf(A))]
Class A: ISomeInterface
{
}
Class B:
{
public A{get;Set;}
}
Its working fine when I am serializing but throws below exception while deserializing.
Error in line 1 position 420. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:anyType' contains data from a type that maps to the name 'http://schemas.datacontract.org/2004/07/SCS.Domain.FormsAndRecordsManagement.Contract.Base:A'. The deserializer has no knowledge of any type that maps to this name. Consider using a DataContractResolver or add the type corresponding to 'A' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.