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

标签 c# .net web-services configuration .net-2.0

一些背景: 我有一个带有 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/

相关文章:

web-services - 寻找 VoIP 服务提供商

c# - C# (.Net) 中的浏览器检测

c# - .net 4.0 中的 MemoryCache 与 ObjectCache 有什么区别?

web-services - 用于业务逻辑或数据访问层的 Web 服务

c# - 如何在 IIS(Internet 信息服务)的 Web 服务中使用 FileStream 上传文件(大尺寸)

c# - ComputeHash 调用莫名其妙地不同

c# - 将 XML 转换为 JSON 到 C# 对象

c# - 将任务添加到 List<Task> 执行它们使 Task.WhenAll() 变得多余

C# - Windows 通用应用程序 - 图像源不起作用

c# - 如何比较两个 .NET 对象图的差异?