Laoujin
Laoujin

Reputation: 10229

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

We've got the following projects:

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?

Upvotes: 0

Views: 571

Answers (1)

Hanno
Hanno

Reputation: 1027

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.

Upvotes: 1

Related Questions