WCF MSMQ unable to serialize interface of DataContract

Posted on 2009-12-22
Last Modified: 2012-05-08

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

Question by:DEALOGIC
    1 Comment
    LVL 35

    Accepted Solution

    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

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now