开发者

Interface type as property of class throws error on client WCF

开发者 https://www.devze.com 2023-01-29 01:17 出处:网络
Hi I have a class which has a property of type of an interface public class A { public List<IInterface> interface {get;set;}

Hi I have a class which has a property of type of an interface

public class A
{
  public List<IInterface> interface {get;set;}
}

Public class B : IInterface
{
  // Some properties 
}

A wcf service is calling a OpertaionContract which return an object type of this object but it fails on my client.

I had already added the ServiceKnowType attribute on all implemented classes on the service contract but still i am getting the same error "Consider using a DataContractResolver or add the type corresponding to 'B' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types pass开发者_如何学Pythoned to DataContractSerializer

I am really confused how this would work , please advise thanks.

I added the KnowTypeAttribute at the right datacontract so the above error went away but now I am getting a generic error of underline connection got closed.

Updated:This link helped me out in resolving the Interface issue How can I pass a List<Interface> over WCF? But right now enums are giving me a similar issue my object breaks on client cause of enums properties being defined in the class.


for your enum problem, are you using EnumMember for the enums? See http://www.codekeep.net/snippets/0002f271-1418-4027-b19a-3820702fc22f.aspx for an example.

If that doesn't solve it, can you share the error message you're getting with the enum usage?

0

精彩评论

暂无评论...
验证码 换一张
取 消