您必须使用ChannelFactory类。
这是一个例子:
var myBinding = new BasicHttpBinding();var myEndpoint = new EndpointAddress("http://localhost/myservice");using (var myChannelFactory = new ChannelFactory<IMyService>(myBinding, myEndpoint)){ IMyService client = null; try { client = myChannelFactory.CreateChannel(); client.MyServiceOperation(); ((ICommunicationObject)client).Close(); myChannelFactory.Close(); } catch { (client as ICommunicationObject)?.Abort(); }}
相关资源:
- 如何:使用ChannelFactory
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)