0

I have a multi project solution where one application is a mvc web application and the others are dlls. I really like that ApplicaitonSettings are strongly typed. It would be great to have application settings shared across the different projects .I found that configSource allows you to store the settings in a separate xml file, but they must be contained within the project directory. This lead me to adding the file via a link but then I run into the problem where the namespaces are different, such as Web.Properties.Settings vs Service.Properties.Settings. Has anyone been able to do something like this?

<applicationSettings>
    <NAMESPACE.Properties.Settings>
        <setting name="Test" serializeAs="String">
            <value>Test</value>
        </setting>
    </NAMESPACE.Properties.Settings>
</applicationSettings>
NullReference
  • 4,404
  • 12
  • 53
  • 90

1 Answers1

2

Yes, config files are hierarchical. So you can put the settings you want to be shared by multiple application at an appropriate level

Emmanuel N
  • 7,350
  • 2
  • 26
  • 36
  • As far as I can tell certain parts of config files are hierarchical, but not all. If I create an ApplicationSettings section in both a web and a dll project when I run the web application the application settings for the dll still apply. – NullReference Dec 28 '11 at 22:20
  • Child sections overwrites parent sections, so for shared sections you don't need to have them on child sections – Emmanuel N Dec 28 '11 at 22:23
  • I don't understand, what do you mean on child? – NullReference Dec 28 '11 at 22:24
  • Machine.Config is at server level, and web.config is at web/application pool level. So, web.config is a child of machine.config. Or web.config files in application pools are childens to web.config at asp.net application root. – Emmanuel N Dec 28 '11 at 22:29
  • Right, that works with appSettings. I don't think the hierarchical part of the web.config doesn't applies to ApplicationSettings since it contains a namespace. – NullReference Dec 28 '11 at 22:44