4

I create dynamic endpoint like this way on server side:

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();
Freelancer
  • 9,008
  • 7
  • 42
  • 81
Ranjita Das
  • 443
  • 2
  • 6
  • 14

1 Answers1

1

I don't know what is your mean here for dynamic endpoint but you can host the service endpoint in app.confog by using the below code in app.config. This app.config must be in that project which is the main project.

<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>
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
Jatin Khurana
  • 1,155
  • 8
  • 15
  • dynamic means i want to create endpoint like this way:" net.tcp://localhost:5054/player/1 " to "net.tcp://localhost:5054/player/5". – Ranjita Das Apr 12 '13 at 04:49
  • The OP wants to add new items to the config file from within the program itself - "dynamic" modification of the config file. – Simon MᶜKenzie Apr 12 '13 at 04:54
  • Configuration Manager is used to modify the app.config file. You can use this to update or read the config file – Jatin Khurana Apr 12 '13 at 07:02