0

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

4

1 回答 1

0

我不是 100% 确定我理解您在这里尝试做的所有事情,但对我来说似乎是颠倒的。使用 KnownType 属性的常用方法是用派生类型修饰基类型。类似于以下内容:

[DataContract]
[KnownType(typeof(Pet))]
[KnownType(typeof(...
...
public class Element: IElement
{
....
于 2010-07-09T00:52:53.247 回答