2012-08-12 25 views
0

我在客户端有一个wcf配置。我需要在AppSettings中使用密钥ServerIP App.Config中的其他部分的名称而不是localhost,因为我的端点数很多,而且我的服务器ip是可变的。我怎么能呢?如何使用app.config本身的AppSettings

<?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> 

回答

0

通常情况下,你不能这样做,但你也许可以,如果你正在使用的VisualStudio 2010年,我认为你必须使用网络部署或运行​​自己的MSBuild任务运行变换使用web.config transformations

相关问题