目前对WCF了解还不是太多,从目前看到的资料,还是觉得使用手写App.config文件是灵活的多,可随时改变EndPoint的配置。

服务端倒容易启动,客户端没有找到打开通道的方式,网上多种方法都不适合,经过查询发现以下办法实现:

Client中配置信息:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>

    <client>
      <endpoint address="net.tcp://192.168.0.2:8210/BaseService" binding="netTcpBinding"
                contract="AGC.Join.Service.IBaseService"   name="myHost"/>
    </client>
  </system.serviceModel>
</configuration>

 

调用服务代码:

ChannelFactory<IBaseService> channel = new ChannelFactory<IBaseService>("myHost");
 IBaseService client = channel.CreateChannel();

 

好不容易找到这里才解决的:http://www.pin5i.com/showtopic-22907.html###

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-08-13
  • 2021-05-18
猜你喜欢
  • 2021-05-31
  • 2021-11-30
  • 2021-08-23
  • 2021-11-05
相关资源
相似解决方案