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?

11 Answers 11

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

10
  • 6
    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.
    – Adam
    Commented Sep 22, 2014 at 4:10
  • 9
    If you click OK before selecting a different row, it doesn't recognize the change.
    – AaronLS
    Commented Oct 31, 2014 at 6:07
  • 6
    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. Commented Jan 23, 2015 at 16:31
  • 1
    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.
    – juFo
    Commented May 17, 2018 at 8:28
  • 1
    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. Commented May 20, 2019 at 6:51
39
+25

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

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. Commented Aug 14, 2012 at 23:09
  • 9
    In my case, with the problem as described in the question, using Visual Studio 2013, there was no EnterpriseLibrary.Configuration.xsd on the machine. Commented Jan 23, 2015 at 16:29
  • 7
    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. Commented Jan 6, 2016 at 23:27
  • 6
    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.
    – ahwm
    Commented Aug 23, 2017 at 14:17
  • what eventually worked permanently for me what to delete the .suo as mentioned below Commented Apr 4, 2019 at 13:39
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.

2
  • 4
    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.
    – RobCroll
    Commented May 3, 2015 at 23:55
  • 1
    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. Commented Sep 28, 2015 at 13:28
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.

5
  • 3
    I was having a similar issue with the VS 2017 RC and this worked also, Thanks
    – TrtlBoy
    Commented Nov 30, 2016 at 6:00
  • 6
    It helped. In my case, the file was located in {solution}/.vs/{project}/v14/.suo
    – Yan F.
    Commented Mar 16, 2017 at 17:37
  • 2
    This worked in the actual release of VS 2017 as well!
    – user3092503
    Commented May 12, 2017 at 12:54
  • 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) Commented Apr 4, 2019 at 13:41
  • 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 Commented Apr 4, 2019 at 14:10
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.

2
  • 1
    I was also unsuccesful in using the GUI, I renamed the generic DotNetConfig.xsd in the 1033\ subfolder and that immediately fixed my problem.
    – Brunis
    Commented May 7, 2015 at 17:10
  • 2
    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) Commented Apr 4, 2019 at 13:44
6

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

5

I noticed this issue with my VS2017.

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

enter image description here

1
  • 3
    this doesn't seem to work permanently (only worked once for a while for me). Delete the .suo file and reopen instead Commented Apr 4, 2019 at 13:50
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).

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.

0
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

0
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.

2
  • Thanks, I passed this problem, but good for others to see there is a solution; upvoted. Commented Jan 10, 2019 at 14:51
  • 4
    just delete the .suo file Commented Apr 4, 2019 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.