[英]Inherit generic class T must be a reference type
public class _Base_Client<T> : System.ServiceModel.ClientBase<T>
It complains that The type 'T' must be a reference type in order to use it as parameter 'TChannel'
它抱怨
The type 'T' must be a reference type in order to use it as parameter 'TChannel'
T is a reference to an interface. T是对接口的引用。
Here is the line I wish to change to use the new base class 这是我希望更改为使用新基类的行
public class EchoServiceClient :
System.ServiceModel.ClientBase<IEchoService>, IEchoService
How can I fix this? 我怎样才能解决这个问题? thanks
谢谢
Change: 更改:
public class _Base_Client<T> : System.ServiceModel.ClientBase<T>
To: 至:
public class _Base_Client<T> : System.ServiceModel.ClientBase<T> where T : class
The constraints in your class must be at least as strict as the constraints defined in its base class ( ClientBase
). 类中的约束必须至少与其基类(
ClientBase
)中定义的约束一样严格。 To wit, here is the declaration of ClientBase
: 也就是说,这是
ClientBase
的声明:
public abstract class ClientBase<TChannel> : ICommunicationObject,
IDisposable where TChannel : class
Notice the class
constraint. 注意
class
约束。
You can't use the interface in there. 你不能在那里使用界面。 You need a concrete implementation of
IEchoService
. 您需要
IEchoService
的具体实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.