我有一个数据合同作为我的 WCF 接口的一部分,它继承自 IIdentity:
[DataContract]
public class AuthenticationIdentity : IIdentity
{
//implements IIdentity...
}
该服务返回我的 AuthenticationIdentity 对象就好了。但是,当我尝试对客户端进行明显的转换时:
AuthenticationIdentity aId = client.GetID();
IIdentity id = aId;
我收到一条投诉,称 AuthenticationIdentity 无法转换为 IIdentity。我尝试将 ServiceKnownTypes 添加到界面:
[ServiceKnownType(typeof(AuthenticationIdentity))]
[ServiceKnownType(typeof(IIdentity))]
但仍然没有运气。有任何想法吗?