如何在服务器app.config中保存动态端点?

时间:2013-04-12 04:22:26

标签: c# wpf wcf c#-4.0 wcf-data-services

我在服务器端以这种方式创建动态端点:​​

var host = new ServiceHost(typeof(PokerService.PlayerService));
 for(int i = 1; i <= ; i++)
 {
   host.AddServiceEndpoint(typeof(PokerService.IPlayerService), 
                                  new NetTcpBinding(),
                                  @"net.tcp://localhost:5054/player/"+i);
 }
 host.Open();

1 个答案:

答案 0 :(得分:1)

我不知道你在这里对动态端点的意思是什么,但你可以使用app.config中的下面代码在app.confog中托管服务端点。此app.config必须位于该项目中,该项目是主项目。

<system.serviceModel>     
        <services>
          <service name="PokerService.PlayerService">
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:5054/player/" />
              </baseAddresses>
            </host>
            <endpoint address="" binding="netTcpBinding" contract="PokerService.IPlayerService" >
    </endpoint>
          </service>
        </services>
      </system.serviceModel>