<endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
把mexTcpBinding改个不一样的端口
感谢简爱的建议,我想简爱的InvokeMyMethod指的就是我的Divide方法,是不?
感觉简爱小姐的第一种写法比较简洁,谢谢。
try{
ChannelFactory<Imath> factory=new ChannelFactory<Imath>();
mathProxy=factory.CreateChannel();
}
.
.
finally{
IChannel channel=mathProxy as IChannel;
....}
既然factory.CreateChanel()方法创造的是通道对象,它当然实现了IChannel接口,我觉得没必要这样显示声明了,可以这样释放通道对象
Imath mathProxy=factory.CreateChannel();
using(mathProxy as IDisposable)
{
mathProxy.InvokeMyMethod();
}
或者
Imath mathProxy=factory.CreateChannel();
mathProxy.InvokeMyMethod();
ICommunicationObject channel=mathProxy as ICommunicationObject;
channel.close():
另外,支持博主!