Question : WCF MSMQ unable to serialize interface of DataContract

Hi,

I am trying to send a datacontract object to message queue. one of the property is return a interface type.

I get this errors:

{"Cannot serialize member Dealogic.ClientManager.Domain.DataTransferObjects.
ContentTransferObject.Analyst of type Dealogic.ClientManager.Domain.Interfaces.
IAnalyst because it is an interface."}

did I miss any attribute?
One of the solution I found is changing the IAnalyst to an abstract class and use XMLInclude
but that would require a major change. any other work around?

thank you,
DL
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
[DataContract]
    [KnownType( typeof( AnalystTransferObject ) )]
        public class ContentTransferObject : BaseTransferObject, IContent  {

        [DataMember]
        public ContentType ContentType { get; set; }

        [DataMember]
        public int ContentNo { get; set; }

        [DataMember]
        public string Headline { get; set; }

        [DataMember]
        public IAnalyst Analyst { get; set; }
}

Answer : WCF MSMQ unable to serialize interface of DataContract

WCF can not return Interfaces because it does not know what instance to return.
The workaround is to use ServiceKnownType and specify all classes that will use this interface.

Check:
http://www.thoughtshapes.com/WCF/UsingInterfacesAsParameters.htm
Random Solutions  
 
programming4us programming4us