我在客户端有一个 wcf 配置。我需要在 AppSettings by ServerIP
Name 中为 App.Config 中的其他部分使用一个键,而不是localhost
,因为我的端点数量很多,而且我的服务器 ip 是可变的。我该怎么办?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ServerIP" value="localhost"/>
</appSettings>
<system.serviceModel>
<bindings>
...
</bindings>
<client>
<endpoint address="net.tcp://localhost:9000/WcfServices/Person/PersonService"
binding="netTcpBinding" bindingConfiguration="RCISPNetTcpBindingWpf"
contract="Common.ServiceContract.IPersonService" name="BasicHttpBinding_IPersonService">
<identity>
<dns value="localhost" /> <!--How use ServerIP in appSettings instead of localhost-->
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>