gpt4 book ai didi

C# app.config 问题 - ConfigurationErrorsException : Unrecognized element 'setting'

转载 作者:行者123 更新时间:2023-11-30 13:05:58 25 4
gpt4 key购买 nike

一些背景:我有一个带有 5 个 Web 引用的 Windows 服务,在开发、测试、QC 的几个环境中一切都很好。开发和测试正在运行 windows 2003、QC 和 PROD windows 2000。我们使用相同的程序集和配置文件集将服务推送到生产环境,但收到此错误。通过同一个代码块,异常不一致。其他使用相同标准配置元素的 Web 引用正在运行。

异常:

 System.Xml.XmlDocumentSystem.Configuration.
ConfigurationErrorsException: Unrecognized
element 'setting'

示例配置部分:

<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup,
System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Blah.AWD.SubSystem.AUE.Properties.Settings"
type="System.Configuration.ClientSettingsSection,
System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>


<applicationSettings>
<Blah.AWD.SubSystem.AUE.Properties.Settings>
<setting name=
"AWD_SubSystem_AUE_WebService_Validator_AppEntryValidator"
serializeAs="String">
<value>http://blah.asmx</value>
</setting>
</Blah.AWD.SubSystem.AUE.Properties.Settings>
</applicationSettings>

我会接受 John 的回答是正确的,因为它最终成为部署问题并且特定于环境。配置实际上没有任何问题。

异常:

 System.Xml.XmlDocumentSystem.Configuration.
ConfigurationErrorsException

如果您在配置中放置了一个无法识别且无法从自定义配置类序列化的元素,则会导致此问题。

最佳答案

您是否 100% 确定生产环境与其他环境使用相同版本的 .NET?如果完全相同的代码(您确定所有程序集都已正确删除?)在 5 个环境中正确运行,但在生产环境中出现问题,这听起来可能是环境问题。

有没有可能——哎呀——你的产品环境只有 .NET 1.1 可用?或者有问题的 Web 服务被放入 IIS 上的 1.1 AppPool 中? (虽然听起来问题不是 Web 服务,而是 Windows 服务——这应该可以解决最后一个问题……)

关于C# app.config 问题 - ConfigurationErrorsException : Unrecognized element 'setting' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/868757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com