public class _Base_Client<T> : System.ServiceModel.ClientBase<T>
它抱怨:类型'T'必须是引用类型才能将其用作参数'TChannel'
T是接口的引用。
这是我希望更改以使用新基类的行:
public class EchoServiceClient :
System.ServiceModel.ClientBase<IEchoService>, IEchoService
如何解决这个问题?谢谢
变更:
public class _Base_Client<T> : System.ServiceModel.ClientBase<T>
致:
public class _Base_Client<T> : System.ServiceModel.ClientBase<T> where T : class
你的类中的约束条件必须至少与其基类 (ClientBase
) 中定义的约束条件一样严格。这里是 ClientBase
的声明:
public abstract class ClientBase<TChannel> : ICommunicationObject,
IDisposable where TChannel : class
注意 class
约束。
你不能在那里使用接口。你需要一个 IEchoService
的具体实现。