I am developing a WCF Service in VS 2010 and .NET 4.0.
I am creating the app.config file and I want to specify once the base address for the server.
I’ve declared it into the appConfig section as:
<appSettings>
<add key="base_address" value="net.tcp://localhost:5050/Service1/"/>
</appSettings>
I would like to know how can I reference that key into the service/host/baseaAddressses like:
<service
name="WcfService_callbacks_tcp_auth_username.Service1"
behaviorConfiguration="beh_auth">
<host>
<baseAddresses>
<add baseAddress="!!!here_the_key!!!"/>
</baseAddresses>
</host>
</service>
And in the client/endpoint section like:
<client>
<endpoint address="!!!here_the_key!!!" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IService1" contract="Service1.IService1"
name="NetTcpBinding_IService1">
<identity>
<certificate encodedValue="..." />
</identity>
</endpoint>
</client>
Is there anyway to do this?
Thanks.
You cannot do that out of the box.
Either you specify the base address explicitly in your WCF config
or you read it from the
app.configin code and set it in WCF code (sample for client side – on the service side, you need to call.AddServiceEndpoint()on yourServiceHost):You cannot reference another config settings inside
app.config– the .NET config system just doesn’t support that.