webformsweb-configapplication-settingsweb.config-transformmulti-layer

Override webservice addresses which is onanother dll at Web.Debug.config file


I work on a multi-layer solution, a web forms application. All the WebServices are under a project called WS. There are more than a hundred of them. And I call WS from Web Forms project.

I want to use the test services under the Debug configuration and live system under the Release conf.

app.config of WS library project is

<applicationSettings>
  <WS.Properties.Settings>
    <setting name="settingName"
        serializeAs="String">
      <value>http://test.x.com/a.asmx</value>
    </setting>
  </WS.Properties.Settings>
</applicationSettings>

So I added web.Config these lines

<configSections>
  <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

    ......

    <section name="WS.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </sectionGroup>
</configSections>



<applicationSettings>
  <WS.Properties.Settings>
    <setting name="settingName"
        serializeAs="String">
      <value>http://live.x.com/a.asmx</value>
    </setting>
  </WS.Properties.Settings>
</applicationSettings>

Then it could launch live services.

in web.debug.config I've tried some transformation; however program still connects with the settings in web.debug (launches live services).

<applicationSettings>
  <WS.Properties.Settings xdt:Transform="Replace" xdt:Locator="Match(name)">
    <setting name="settingName"
      serializeAs="String">
      <value>http://test.x.com/a.asmx</value>
    </setting>
 </WS.Properties.Settings>
</applicationSettings>

How should I change the web.debug.config file in order to connect test services in debug configuration.

Thanks,


Solution

  • This selection is only affects publish not debugging section. I've found it but I couldn't have time to share to answer.

    It can be a better solution to use some preprocessor like

    #if DEBUG
    ....
    #endif