KnownTypeAttribute serialization error

It can happen that you get this exception while deserializing an object from xml:

Type ‘xxxx’ with data contract name ‘xxxxxxxxx’ is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.”

Do not despair, this is because the framework need to know what types are nested within the document and what to expect. To fix it, add the KnownType attribute above the unknown class :

public partial class selectionbox

No Comments

You can leave the first : )

Leave a Reply

Your email address will not be published. Required fields are marked *