views:

497

answers:

2

Hi, i've a WCF client wicht refers to multiple services hosted in the same machine. like this example

<client>
   <endpoint address="net.tcp://localhost:8731/TrackingService" binding="netTcpBinding" ...
   </endpoint>
   <endpoint address="net.tcp://localhost:8731/CommonService" binding="netTcpBinding"...
   </endpoint>
</client>

is it possible to modify my app.config in order to keep the

net.tcp://localhost:8731

part of endpoint address in a different variable, so when i'll deploy i have to change it once?

Maybe a programmatically clever way to do this? My only need is to change "address:port".

Thank you in advance

+1  A: 

No, unfortunately, on the client side, there's nothing like a <baseAddress> like on the server side, which you can set globally.

Each endpoint declaration must have the entire, complete URL in it, I'm afraid.

Marc

marc_s
A: 

You can always programmatically create your client and read the address from a normal appconfig value. Like this

MyClient client=
                new MyClient(new BasicHttpBinding(), new EndpointAddress(ConfigurationManager.AppSettings.Get("ServiceAddress");)
Pratik