简体   繁体   中英

web.config and app.config ApplicationSettings being overwritten in ASP.NET

We've got the following projects:

  • Domain.UI.Web
  • Domain.Business
  • Domain.Services.EndPoints
  • Domain.Services.Contracts
  • Domain.Services.Agents

ApplicationSettings are being added to the app.Config in for example the Domain.Business project:

<applicationSettings>
    <Domain.Business.My.MySettings>
        <setting name="SomeKey" serializeAs="String">
            <value>someDummyValue</value>
    </Domain.Business.My.MySettings>
</applicationSettings>

The keys are added there for the typed accessor that is generated by Visual Studio. However the value is being overwritten by the values from the web.config in another project. This is the web.config of the Domain.Services.EndPoints project.

<Domain.Business.My.MySettings>
        <setting name="SomeKey" serializeAs="String">
            <value>actual_value</value>
        </setting>
    </Domain.Business.My.MySettings>
</applicationSettings>

When I get My.Settings.SomeKey from the Domain.Business project the value is the actual_value from the EndPoints project. And this seems to be happening automagically as I couldn't find any code in our solution that seems to be doing this and I can't get Google to answer my question:

What is this? Is this something standard in ASP.NET or WCF? In what version of the framework has this been introduced? Where can I read more about this overwriting behavior?

Since Domain.Bussiness is a class library, it is normal behavior. A dll doesn't have a .config file so it uses the web.config (or app.config in case of an executable) of the application that references the library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM