Fix: The Global element 'configuration' has already been declared

Viewed 71316
11 Answers

I noticed this issue with my VS2017.

Changing DotNetConfig.xsd to use "Automatic" solved the problem.

enter image description here

Using Visual Studio 2015 Community Edition - generating a web.xsd in the root folder of my project and adding it to the schema list cleared all but one of the warnings,

The global element 'configuration' has already been declared'.

Closing the web.config file in the text editor and rebuilding the project cleared this warning.

Necromancing: update 2019 with visual Studio 2017

I tried to do what others suggested:

  • I tried to reboot the system: did not work.
  • open App.Config
  • Menu: XML - Schemas...
  • See that there are several DotNetConfigXX.csd (XX either emoty, or a number)
  • I tried to set them automatic, or to "do not use this schema"
  • I tried to remove duplicate schema's

All this did not work.

However, the solution of OLEG as described here worked.

All I had to do is replace the following part in of all used DotNetConfigXX.xsd files (XX is empty, or a number) with the following code

 <xs:element name="startup" vs:help="configuration/startup" 
 ...
 </xs:element>

Replace with:

<xs:element name="startup" vs:help="configuration/startup">
    <xs:complexType>
        <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="requiredRuntime"     vs:help="configuration/startup/requiredRuntime">
                <xs:complexType>
                    <xs:attribute name="version" type="xs:string" use="optional" />
                    <xs:attribute name="safemode" type="xs:boolean" use="optional" />
                </xs:complexType>
            </xs:element>
            <xs:element name="supportedRuntime" minOccurs="1" maxOccurs="unbounded" vs:help="configuration/startup/supportedRuntime">
                <xs:complexType>
                    <xs:attribute name="version" type="xs:string" use="optional" />
                    <xs:attribute name="sku" type="xs:string" use="optional" />
                </xs:complexType>
            </xs:element>
        </xs:choice>
        <xs:attribute name="useLegacyV2RuntimeActivationPolicy" type="xs:boolean" use="optional" />
        <!-- see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx -->
    </xs:complexType>
</xs:element>

Don't forget to back-up your original .XSD files!

After a restart of visual studio the errors were gone.

Related