I have custom System.Configuration.ConfigurationSection
derived class which represents configuration section in my app.config
file. I also have xsd
schema document for that XML document. Configuration file has the following (simplified) structure:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="sectionOne" type="/*...*/" />
<section name="sectionTwo" type="/*...*/" />
<section name="sectionThree" type="/*...*/" />
</configSections>
<sectionOne xmlns="http://tempuri.org/MySchema.xsd">
<Container>
/*...*/
</Container>
</sectionOne >
<sectionTwo xmlns="http://tempuri.org/MySchema.xsd">
<Container>
/*...*/
</Container>
</sectionTwo >
<sectionThree xmlns="http://tempuri.org/MySchema.xsd">
<Container>
/*...*/
</Container>
</sectionThree >
</configuration>
As we can see, I have a several sections of that type, for various purposes, and I retrieve configuration data using ConfigurationManager
class:
ConfigurationManager.GetSection(sectionName);
Because section name is not constant string value, xsd
schema validate only elements that are children of the root element (starting from Container
tag). Therefore in VS2012, in Error list toolbar, I get a following messages:
Could not find schema information for the element 'http://tempuri.org/MySchema.xsd:SectionOne'.
Could not find schema information for the element 'http://tempuri.org/MySchema.xsd:SectionTwo'.
Could not find schema information for the element 'http://tempuri.org/MySchema.xsd:SectionThree'.
How to fix that validation mechanism.