views:

34

answers:

1

I have a situation where I need to pass a list of objects to my service. The objects have to be of type ELEMENT. I have my Element interface defined like so

public interface IElement{ }

Then I have my DataContracts inheriting this IElement class Like so . . . .

[KnownType(typeof(Common.IElement))]
[DataContract]
public abstract class IPet : IElement
 {.....}

I also have a KnownType attribute on my Service interface like so

[ServiceContract(Name="Pets", SessionMode = SessionMode.Allowed)]
[ServiceKnownType(typeof(Memberships.PetServiceUser))]
[ServiceKnownType(typeof(.Common.IElement))]
[DeliveryRequirements(RequireOrderedDelivery=true)] 
public interface IPetService {.....}

Problem is on the client side, the IElement type is not available on deserialization of service types on client. Any idea what I may be doing wrong here and how I can go about correcting this please?

None

A: 

I'm not 100 percent sure I understand everything you're trying to do here, but is seems upside-down to me. The usual way to use the KnownType attribute is to decorate the base type with the derived types. Something along the lines of:

[DataContract]
[KnownType(typeof(Pet))]
[KnownType(typeof(...
...
public class Element: IElement
{
....
500 - Internal Server Error