在UI中更改app.config中的baseAddress

时间:2015-03-02 03:45:22

标签: c# .net xml app-config

我需要使用UI更改baseAddress,以便用户可以指定要使用的baseAddress。

我已经搜索了很多,似乎无法找到访问baseAddress的解决方案。大多数是如何访问app.config文件中的密钥。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <system.serviceModel>
    <services>
      <service name="IBSCommService.CommService" behaviorConfiguration="mexBehaviour">
        <endpoint address="IBSCommService" binding="basicHttpBinding" contract="IBSCommService.ICommService"></endpoint>
        <!--<endpoint address="IBSCommService" binding="netTcpBinding" contract="IBSCommService.ICommService"></endpoint>-->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://161.100.100.186:8080/"/>
            <!--<add baseAddress="net.tcp://localhost:8090/"/>-->
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

0 个答案:

没有答案