【问题标题】:Is it possible to use an interface type as parameter type in a WCF operation?是否可以在 WCF 操作中使用接口类型作为参数类型?
【发布时间】:2011-11-23 12:53:26
【问题描述】:

有一些界面:

public interface IMessage
{
    string Content;
    Person Sender;
}

public class Priv : IMessage
{
    public string Content { get; set; }
    public Person Sender { get; set; }
    private int whatever;
}

public class Publ : IMessage
{
    public string Content { get; set; }
    public Person Sender { get; set; }
    private DateTime something;
}

是否可以在 wcf 服务IMessage 实例中使用? 喜欢void SomeMethod(IMessage toSend)

【问题讨论】:

标签: c# interface communication wcf


【解决方案1】:

是的,这是可能的。您必须使用 KnownTypes 属性告诉服务您将发送的预期实现列表

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-02
    • 2020-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    相关资源
    最近更新 更多