目前对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###

posted on 2009-07-01 16:48  老白  阅读(713)  评论(0编辑  收藏  举报