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

前端 未结 11 1623
天命终不由人
天命终不由人 2020-12-13 01:30

I used the second solution of How to resolve "Could not find schema information for the element/attribute "?

I.e. created a XSD with the button

相关标签:
11条回答
  • 2020-12-13 01:53

    I noticed this issue with my VS2017.

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

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-13 01:56

    My issue was I went from .Net 4.5 to .Net 4.0. To resolve the issue I switched all the ticked schemas to automatic.

    0 讨论(0)
  • 2020-12-13 01:59

    Rebooting didn't work for me, so I'd like to share what did work.

    First, I just upgraded to Windows 8. This problem didn't occur before then. And this issue only happened in one of my app.config files. So I decided to compare the problematic app.config with a good one. In Visual Studio, with the app.config open, I went to Xml -> Schemas. I noticed that the good config only had three of these schemas checked. The bad one had the same three checked, plus a DotNetConfig.xsd. After I changed the Use column to automatic, for DotNetConfig.xsd, the problem went away.

    enter image description here

    enter image description here

    0 讨论(0)
  • 2020-12-13 02:04

    I had a similar problem to the question you are referring to, I followed these instructions and everything was fine. Make sure the EnterpriseLibrary.Configuration.xsd is in %ProgramFiles%\Microsoft Visual Studio [version]\Xml\Schemas\ first of all, then do this:

    Enterprise Library installs a schema into Visual Studio that provides IntelliSense® for editing Enterprise Library configuration files in the Visual Studio XML editor. You must turn on the schema before you can use it.

    To enable the Enterprise Library configuration schema

    1. Open the configuration file in Visual Studio by double-clicking it in Solution Explorer.
    1. On the XML menu, click Schemas... to open the XML Schemas dialog.
    1. Locate the schema named EnterpriseLibrary.Configuration.xsd. This is installed automatically. However, if it is not shown in the list, click Add and navigate to the folder %Program Files%\Microsoft Visual Studio [version] \Xml\Schemas, then select EnterpriseLibrary.Configuration.xsd and click Open.
    1. Change the value in the Use column to Use this schema. Then click OK.

    Link to the article is here , hopes this helps

    0 讨论(0)
  • 2020-12-13 02:10

    I struggled with this for a while as well. Turns out, my version of the problem originated from the hidden {PROJECTNAME}.SUO file created by Visual Studio.

    My guess is, VS will cache the XSD schema associations in this file. The warnings popped up after I changed the target framework, and they disappeared after I deleted the SUO file and restarted VS.

    0 讨论(0)
提交回复
热议问题