Reputation: 174457
I added a new DTO derived from an already existing DTO to my shared DTO assembly, added the new DTO as KnownType
to the service implementation and as ServiceKnownType
to the service interface.
However, when I am trying to update my client that reuses the DTO assembly, I get the following exception:
Type 'MyNewDerivedTypeDto' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
However, none of my DTOs has the DataContract
attribute applied and it works with all of the other DTOs.
Upvotes: 1
Views: 127
Reputation: 174457
This happens when the new DTO class doesn't have a default constructor. Each DTO to be used by the default WCF serializer needs to have a default constructor. Unfortunately, the exception in this case is pretty misleading.
Upvotes: 2