简体   繁体   中英

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

Some background: I have a windows service with 5 web references, Everything works great in several environments Dev,Test,QC. Dev and Test are running windows 2003, QC and PROD windows 2000. We pushed the service to production with the same set of assemblies and config files and are receiving this error. The exception is not consistent through the same block of code. Other web reference are working that use the same standard configuration elements.

The exception :

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

Example config sections:

<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>

I will accept John's answer as being correct because it ended up being a deployment issue and was specific to the environment. Nothing was actually wrong with the config.

The exception:

 System.Xml.XmlDocumentSystem.Configuration.
ConfigurationErrorsException

is caused if you put an element in your config that is not recognized and not able to be serialized from the custom configuration class.

Are you 100% sure that the production environment is on the same version of .NET as your others? If the exact same code (you're sure all assemblies were dropped correctly?) runs correctly in 5 environments, and pukes in production, it sounds like it may be an environmental issue.

Is it possible that -- gah -- your prod environment only has .NET 1.1 available? Or that the web service in question was dropped into a 1.1 AppPool on IIS? (Although it sounds like the issue isn't the web service, but the Windows service -- which should moot out the last question ... )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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