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

70,076

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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.

Share:
70,076

Related videos on Youtube

Michel Keijzers
Author by

Michel Keijzers

I'm a professional software engineer, working at Altran. I have interest in OO languages and have C++/C# knowledge (MCTS, WinForm, WPF applications). Until recently, I wrote an app for Korg music synthesizers (PCG Tools) and try to learn myself WPF at the same time. Lately, I'm into Arduino/STM32, learning the basics (and more) of electronics, and trying to build a MIDI/DMX device for MIDI keyboards and DMX512 lighting devices.

Updated on July 05, 2022

Comments

  • Michel Keijzers
    Michel Keijzers almost 2 years

    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?

  • Michel Keijzers
    Michel Keijzers almost 12 years
    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.
  • Adam
    Adam over 9 years
    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.
  • AaronLS
    AaronLS over 9 years
    If you click OK before selecting a different row, it doesn't recognize the change.
  • John JB
    John JB over 9 years
    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.
  • Vetras
    Vetras over 9 years
    Solved the issue. Thanks
  • Charles Oppermann
    Charles Oppermann over 9 years
    In my case, with the problem as described in the question, using Visual Studio 2013, there was no EnterpriseLibrary.Configuration.xsd on the machine.
  • Charles Oppermann
    Charles Oppermann over 9 years
    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.
  • RobCroll
    RobCroll about 9 years
    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.
  • Brunis
    Brunis about 9 years
    I was also unsuccesful in using the GUI, I renamed the generic DotNetConfig.xsd in the 1033\ subfolder and that immediately fixed my problem.
  • Daniel Gimenez
    Daniel Gimenez over 8 years
    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.
  • Peter T. LaComb Jr.
    Peter T. LaComb Jr. over 8 years
    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.
  • Philippe Raemy
    Philippe Raemy almost 8 years
    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.
  • TrtlBoy
    TrtlBoy over 7 years
    I was having a similar issue with the VS 2017 RC and this worked also, Thanks
  • Crispy Ninja
    Crispy Ninja over 7 years
    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.
  • Yan F.
    Yan F. about 7 years
    It helped. In my case, the file was located in {solution}/.vs/{project}/v14/.suo
  • arbitrarystringofletters
    arbitrarystringofletters about 7 years
    This worked in the actual release of VS 2017 as well!
  • Mark Baijens
    Mark Baijens about 7 years
    Could not change this option in VS 2017. Charles solution to rename the file helped. Thanks!
  • ahwm
    ahwm almost 7 years
    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.
  • juFo
    juFo about 6 years
    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.
  • Rolan
    Rolan over 5 years
    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.
  • Michel Keijzers
    Michel Keijzers over 5 years
    Thanks, I passed this problem, but good for others to see there is a solution; upvoted.
  • George Birbilis
    George Birbilis about 5 years
    what eventually worked permanently for me what to delete the .suo as mentioned below
  • George Birbilis
    George Birbilis about 5 years
    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)
  • George Birbilis
    George Birbilis about 5 years
    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)
  • George Birbilis
    George Birbilis about 5 years
    just delete the .suo file
  • George Birbilis
    George Birbilis about 5 years
    this doesn't seem to work permanently (only worked once for a while for me). Delete the .suo file and reopen instead
  • George Birbilis
    George Birbilis about 5 years
    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 it
  • Lionet Chen
    Lionet Chen about 5 years
    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.