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

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

WCF MSMQ unable to serialize interface of DataContract


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,
    [KnownType( typeof( AnalystTransferObject ) )]
        public class ContentTransferObject : BaseTransferObject, IContent  {

        public ContentType ContentType { get; set; }

        public int ContentNo { get; set; }

        public string Headline { get; set; }

        public IAnalyst Analyst { get; set; }

Open in new window

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.


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