DataContractSerializer KnownType attribute not being respected?

Posted by e28Makaveli on Stack Overflow See other posts from Stack Overflow or by e28Makaveli
Published on 2010-04-19T21:11:46Z Indexed on 2010/04/19 21:23 UTC
Read the original article Hit count: 708

Filed under:
|

I have a class that is decorated with a KnownType attribute with a type of the class. Is this not allowed?

  [KnownType(typeof(Occ600UIConfig))]
    public class Occ600UIConfig 
    { }

If so, why is the DCS throwing the following exception?

{"Error in line 1 position 387. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value' contains data of the 'http://schemas.datacontract.org/2004/07/OCC600.Infrastructure.Dictionary.BusinessEntities:Occ600UIConfig' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Occ600UIConfig' 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."}

© Stack Overflow or respective owner

Related posts about datacontracts

Related posts about wcf