Unrecognized attribute "xmlns" in user .config file

I created a custom System.Configuration.ConfigurationSection , which I store in a separate configuration file and include it in my web.config via 'configSource="MyCustomConfigFile.config"'

I also created an .xsd schema for a custom configuration file to add some useful properties, such as checking the / intellisense schema, which works well.

When I try to start an application (which is hosted in IIS8, .NET 4.5.1), I get the following error:

Configuration Error Description: An error occurred while processing the configuration file required to service this request. Review the specific error data below and modify the configuration file.

Parser error message: unrecognized attribute "xmlns". Note that attribute names are case sensitive.

Source Error:

Line 1: <? xml version = "1.0" encoding = "utf-8"? >

Line 2: <identityServer xmlns = "http: //myCustomNamespace.xsd">

Honestly, I am surprised - can anyone tell me how to fix this without deleting xmlns so that I can maintain the / intellisense schema validation?

+5
source share
2 answers

Using the information found here, it became clear that the parser does not deserialize the configuration section because the configuration section does not know about the "xmlns" attribute - which really makes PERFECT meaning.

To fix this, you can add the following to your customizing section in C #:

  public class MyCustomConfigurationSection { private const string XmlNamespaceConfigurationPropertyName = "xmlns"; [ConfigurationProperty(XmlNamespaceConfigurationPropertyName, IsRequired = false)] public string XmlNamespace { get { return (string)this[XmlNamespaceConfigurationPropertyName]; } set { this[XmlNamespaceConfigurationPropertyName] = value; } } } 

This completely fixes the problem.

+11
source

I did not encounter this specific problem myself, but you could try to delete the "obj" folder in your project and rebuild, as suggested in the next post.
Web.config conversion: unrecognized attribute 'xmlns: xdt'. Please note that attribute names are case sensitive.

-1
source

Source: https://habr.com/ru/post/1211794/


All Articles