Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Is it possible to move applicationSettings to another config file as it is possible with connectionStrings or appSettings?

When I create Settings for my web application using the designer I get applicationSettings section in my web.config such as:

  <applicationSettings>
    <TestWebApplication.Properties.Settings>
      <setting name="AnotherSetting" serializeAs="String">
        <value>Another setting value</value>
      </setting>
    </TestWebApplication.Properties.Settings>
  </applicationSettings>

I would like to be able to move them to another file like appSettings:

<appSettings configSource="configappsettings.config"/>

I'm working with a project that has lots of settings accessed through class generated with designer and web.config is extremely hard to maintain between multiple environments. It would be even better if I could force Settings class to use appSettings not applicationSettings.

Is it possible?

Thanks in advance for help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
466 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waaaay late for this question, but I've just been banging my head against the wall over this one. Turns out you can do this, just not for the entire applicationSettings node, you have to do each child node of the applicationSettings separately. I got the magic info from the bottom of the MSDN SectionInformation.ConfigSource article.

app.config/web.config contents

<applicationSettings>
    <TestWebApplication.Properties.Settings configSource="externalfile.config" />
</applicationSettings>

externalfile.config contents:

<TestWebApplication.Properties.Settings>
    <setting name="AnotherSetting" serializeAs="String">
        <value>Another setting value</value>
    </setting>
</TestWebApplication.Properties.Settings>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

Just Browsing Browsing

[2] html - How to create even cell spacing within a

548k questions

547k answers

4 comments

86.3k users

...