【发布时间】:2008-11-21 20:54:24
【问题描述】:
我正在试验 WCF 服务,但在传递接口时遇到了问题。
这行得通:
[ServiceContract]
public interface IHomeService
{
[OperationContract]
string GetString();
}
但这不是:
[ServiceContract]
public interface IHomeService
{
[OperationContract]
IDevice GetInterface();
}
当我尝试编译客户端时,它在 GetInterface 方法上失败。我收到一个异常,说它无法将 Object 转换为 IDevice。
在客户端,IHomeService 类正确地使用字符串实现 GetString 作为它的返回类型,但 GetInterface 具有对象的返回类型。为什么不是 IDevice?
【问题讨论】: