使用 configSource,并更改核心部分的 restartOnExternalChanges

发布于 2024-08-05 00:00:12 字数 922 浏览 1 评论 0原文

我想使用 configSource 属性我的网络配置部分来定义各种设置的外部文件。

特别是应用程序设置部分。这意味着我的配置文件具有以下条目:

<appSettings configSource="My.AppSettings.config" />

但是,如果更新此文件,则不会自动拾取设置,如果将设置手动包含在 web.config 中,则会出现这种情况

进一​​步调查导致我发现 < href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.restartonexternalchanges.aspx" rel="noreferrer">restartOnExternalChanges 属性。这显然可以与

元素一起使用来定义 configSource 标识的外部文件是否可以触发重新启动。伟大的!至少我是这么想的。

但是,当尝试定义 appSettings 部分并更改 restartOnExternalChanges 值时,我看到遇到相同的错误 此处,因为 appSettings 部分是在 machine.config 中定义的 - 我无法更改该文件。

有谁知道对于已经在更高级别定义的部分是否可以让这两个设置一起工作?

I'd like to use the configSource attribute of my web config section to define external files for various settings.

Particularly, the appSettings section. This means my config file has the following entry:

<appSettings configSource="My.AppSettings.config" />

However, if this file is updated, the settings are not automatically picked up, which would have been the case if the settings were manually included in the web.config

Further investigation lead me to the restartOnExternalChanges attribute. This can apparently be used with <section/> elements to define whether externals files identified by configSource can trigger restarts or not. Great! or so I thought.

However, when trying to define the appSettings section, and changing the restartOnExternalChanges value, I see the same error encountered here, because the appSettings section is defined in the machine.config - a file I cannot change.

Does anyone know if its possible to get these two settings to work together, for sections already defined at a higher-level?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待天淡蓝洁白时 2024-08-12 00:00:12

请尝试使用此配置。

<section 
    name="MyAppSettings" 
    type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    restartOnExternalChanges="true" 
    requirePermission="false" />

Try this configuration instead.

<section 
    name="MyAppSettings" 
    type="System.Configuration.AppSettingsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    restartOnExternalChanges="true" 
    requirePermission="false" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文