简体   繁体   English

web.config和app.config ApplicationSettings在ASP.NET中被覆盖

[英]web.config and app.config ApplicationSettings being overwritten in ASP.NET

We've got the following projects: 我们有以下项目:

  • Domain.UI.Web Domain.UI.Web
  • Domain.Business 领域业务
  • Domain.Services.EndPoints 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添加到app.Config中,例如Domain.Business项目:

<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. 密钥被添加到此处,用于由Visual Studio生成的类型化访问器。 However the value is being overwritten by the values from the web.config in another project. 但是,该值被另一个项目中web.config中的值覆盖。 This is the web.config of the Domain.Services.EndPoints project. 这是Domain.Services.EndPoints项目的web.config

<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. 当我从Domain.Business项目中获取My.Settings.SomeKey ,该值就是EndPoints项目中的actual_value 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: 这似乎是自动发生的,因为我在我们的解决方案中找不到似乎正在执行此操作的任何代码,而我也无法让Google回答我的问题:

What is this? 这是什么? Is this something standard in ASP.NET or WCF? 这在ASP.NET或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. 由于Domain.Bussiness是一个类库,因此是正常行为。 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. dll没有.config文件,因此它使用引用该库的应用程序的web.config(或在可执行文件的情况下为app.config)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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