Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1322
  • Last Modified:

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
[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; }
}

Open in new window

0
DEALOGIC
Asked:
DEALOGIC
1 Solution
 
Miguel OzSoftware EngineerCommented:
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
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now