Fix: The Global element 'configuration' has already been declared
Asked Answered
K

11

82

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

I.e. created a XSD with the button to create a scheme. I changed the stylesheet in app.config to app.xsd but now I get the warning:

The Global element 'configuration' has already been declared in app.xsd

Even when changing the name the warning is shown. Does anybody have a solution for this?

Kristynkrock answered 5/8, 2012 at 13:41 Comment(0)
P
39

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

Pomeroy answered 14/8, 2012 at 9:42 Comment(5)
Thanks ... however I cannot reproduce the problem anymore. When I restarted my computer (which I seldom do) the warnings are removed, so I cannot tell right now if your solution works. But since you gave a solution I upvoted it anyway.Kristynkrock
In my case, with the problem as described in the question, using Visual Studio 2013, there was no EnterpriseLibrary.Configuration.xsd on the machine.Blockus
This at least sent me in the right direction - the VS 2013 schemas were loading in VS 2015. Set them to Auto and the error went away.Aholla
Same here @PeterLaCombJr. I reset all the ones that were "Use" to "Automatic" and the errors went away and VS 2017 started validating my app.config correctly again and gave me IntelliSense.Heloise
what eventually worked permanently for me what to delete the .suo as mentioned belowCruickshank
V
202

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

Voltaic answered 3/1, 2013 at 4:16 Comment(10)
It was DotNetConfig.xsd for me to. I wonder if it was because of changing the .net build version, since I noticed a DotNetConfig45 as well.Forde
If you click OK before selecting a different row, it doesn't recognize the change.Cheung
After updating, it I restarted visual studio which fixed the issue. I made DotNetConfig.xsd to automatic. I had switched my project Frame Target Framework from 4.0 to 4.5 and reverted it. May be it caused this issue.Lordsandladies
This did not help me. No matter what I did, "Do not use", "Automatic" or Remove, both the DotNetConfig40.xsd and DotNetConfig.xsd were being selected. I tried ensuring that I selected another row after making the selection. I finally had to rename DotNetConfig.xsd to "DotNetConfig DO NOT USE.xsd" to prevent it from loading.Blockus
It helped me, thanks. Still I ad the same issue as Charles Oppermann above, which was resolved by closing and reopening the solution in Visual Studio 2015.Khanna
This didn't solve for me but pointed me in the right direction. In one of my projects I saw several configs for VS 2013 and VS 2015 in the XML Schema windows. Setting the VS 2013 schemas to "Do not use" fixed the issue for me.Blackmarketeer
Could not change this option in VS 2017. Charles solution to rename the file helped. Thanks!Tincture
I opened app.config noticed the message. next went to XML >> Schemas >> I noticed DotNetConfig.xsd and DotNetConfig45.xsd. I changed for DotNetConfig.xsd the [Use] to Automatic. restarted visual studio 2017 and it was solved now.Extravagate
I was able to change the option in VS2017. It looks like there's conflicting schemas which causes the "element" has already been declared warning.Factory
If you're updating from previous Visual Studio versions you might have multiple schemas of the same name ticked, each for a previous version. Put 'automatic' in all of them except the latest version will fix the issue. Mind that the schemas selection is unique for each .config file so changing needs to be made for each .config file.Capua
P
39

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

Pomeroy answered 14/8, 2012 at 9:42 Comment(5)
Thanks ... however I cannot reproduce the problem anymore. When I restarted my computer (which I seldom do) the warnings are removed, so I cannot tell right now if your solution works. But since you gave a solution I upvoted it anyway.Kristynkrock
In my case, with the problem as described in the question, using Visual Studio 2013, there was no EnterpriseLibrary.Configuration.xsd on the machine.Blockus
This at least sent me in the right direction - the VS 2013 schemas were loading in VS 2015. Set them to Auto and the error went away.Aholla
Same here @PeterLaCombJr. I reset all the ones that were "Use" to "Automatic" and the errors went away and VS 2017 started validating my app.config correctly again and gave me IntelliSense.Heloise
what eventually worked permanently for me what to delete the .suo as mentioned belowCruickshank
A
35

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.

Affray answered 18/2, 2015 at 17:36 Comment(2)
You will find schemas in the the properties window of the app.config file. Click on the Schemas ellipse button and replace each tick with Automatic from the dropdown.Pung
I tried removing the offending schema individually, but it kept coming back. Only when I set all schemas to automatic did the schema I wanted to go away actually leave.Expiratory
E
27

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.

Economize answered 20/11, 2015 at 9:37 Comment(5)
I was having a similar issue with the VS 2017 RC and this worked also, ThanksDamarisdamarra
It helped. In my case, the file was located in {solution}/.vs/{project}/v14/.suoTeleview
This worked in the actual release of VS 2017 as well!Unclench
thanks, this fixed it permanently (rename of the .xsd file to _.xsd also worked). BTW, deletion of the .suo ended up with the DotNetConfig.xsd and removed the DotNetConfig45.xsd from the list (had converted from 4.5 to 4.7.2 an MVC5 app [which had been recently converted from MVC4] and some console apps and libraries before the issue appeared)Cruickshank
btw, as I mention at zoomicon.wordpress.com/2019/04/04/… I just found a ".suo" file with no filename part, just had the file extension and deleted itCruickshank
B
13

With the symptoms as described in the question, and using Visual Studio 2013 (Update 4), I could see in the XML Schemas [sic] dialog that both DotNetConfig.xsd and DotNetConfig40.xsd were selected for use.

I'm using a .NET Framework 4.0 project.

The two XSD files conflict with each other, each defining the same elements, causing the warnings to be emitted.

These schema files are contained in the %programfiles(x86)%\Microsoft Visual Studio 12.0\xml\Schemas\ folder.

DotNetConfig.xsd is in the 1033 sub-folder and appears to be the newer, more complete version.

No matter what settings I selected in XML Schemas, I could not deselect, or remove DotNetConfig40 nor DotNetConfig. I tried "Remove", and changing the Use parameter from "Use this schema" to "Automatic" and then "Do not use this schema".

No matter what was selected, for either file, when I would return to the dialog, both would be selected for use. I also tried the trick of moving to another row before pressing "OK" to no avail.

Finally, I renamed the DotNetConfig40.xsd file to DotNetConfig40 DO NOT USE.xsd to prevent it from being loaded. This immediately solved the problem.

I'm not pleased with having to do that, and worry if it'll have an undesired side effect with other projects. I'll update this post with my results.

Blockus answered 23/1, 2015 at 16:50 Comment(2)
I was also unsuccesful in using the GUI, I renamed the generic DotNetConfig.xsd in the 1033\ subfolder and that immediately fixed my problem.Osorio
thanks, that worked, however deletion of the .suo seems to be the best solution. That kept the DotNetConfig.xsd in the schemas list (removed the DotNetConfig45.xsd that was also there after I had converted from 4.5 to 4.7.2)Cruickshank
Y
6

This issue got fixed once I closed the file in the editor that was causing these warnings and recompiled.

Yocum answered 28/5, 2015 at 22:20 Comment(0)
A
5

I noticed this issue with my VS2017.

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

enter image description here

Archenemy answered 11/9, 2018 at 11:16 Comment(1)
this doesn't seem to work permanently (only worked once for a while for me). Delete the .suo file and reopen insteadCruickshank
K
4

After rebooting the system the problem is solved, meaning I do not get any warnings anymore related to the scheme.

So it seems that rebooting (and possibly some implicit restore/reset removed the warning).

Kristynkrock answered 14/8, 2012 at 23:21 Comment(0)
I
4

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.

Idonna answered 18/10, 2017 at 15:5 Comment(0)
T
4

For me i noticed i had a bunch of XML Schemas that were duplicated, i just simply marked as Don't Use all the ones that weren't related to Visual Studio 2017. The problem immediately disappeared

Trattoria answered 12/3, 2018 at 23:49 Comment(0)
S
3

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.

Secular answered 10/1, 2019 at 14:45 Comment(2)
Thanks, I passed this problem, but good for others to see there is a solution; upvoted.Kristynkrock
just delete the .suo fileCruickshank

© 2022 - 2024 — McMap. All rights reserved.