41

Getting this problem on 3 PCs with a fresh installation of VS 2015 RTM. There are no issues when the file is opened in VS 2013. Steps described in Fix: The Global element 'configuration' has already been declared and other related questions don't help as VS ignores any changes on the XML schema dialog. Ideas?

Community
  • 1
  • 1
nphx
  • 1,426
  • 3
  • 19
  • 30
  • Is this error showing when you open the file, or in Debug, or Live? – SierraOscar Jul 30 '15 at 09:55
  • 1
    @MacroMan Those are warnings shown when web.config is opened. – nphx Jul 30 '15 at 10:54
  • There's also [this question](http://stackoverflow.com/questions/32261126/the-global-element-configuration-has-already-been-declared-when-adding-net-2), whose [solution](http://stackoverflow.com/a/32261974/587467) doesn't work for me either: I removed every reference and it's still happens... Really hope somebody here finds a solution! – Tar Sep 27 '15 at 09:40
  • It's happen after or before the conversion? – abeppler Oct 05 '15 at 17:14
  • @abeppler What conversion? This is a warning produced by VS when I open `web.config` in our ASP.NET project. – nphx Oct 06 '15 at 08:30

3 Answers3

19

Unfortunately, there are a number of situations that can cause this problem.

The most likely problem though is that the schema for the document has been set incorrectly. This can happen when you install a newer version of .NET and/or Visual Studio on the computer. The fix is simple though.

From the Visual Studio documentation:

  1. Open a file in the XML editor.
  2. In the document properties window, click the button on the Schemas field.

    The XML Schemas dialog box is displayed. The dialog box lists all schemas with an .xsd extension in the schema cache (including schemas referenced in the catalog.xml file), and also any schema that is in the current solution, open in Visual Studio, referenced in an xsd:schemaLocation attribute, or referenced in the Schemas property.

  3. Select the schemas to use for validation by doing one of the following:
    • Select a schema listed in the XML Schemas dialog, click the Use column, and then select Use this schema. -OR-
    • Select multiple schemas listed in the XML Schemas dialog, right-click and select Use this schema.
  4. Click OK.

Specifically, you want to set the "Use" column for the "DotNetConfig.xsd" schema to "Auto".

  • 4
    For me, I had duplicate entries selected. Deselecting the duplicate got rid of the error for me. This post put me on the right path. – E Lewis Feb 12 '16 at 02:10
  • 1
    Ditto. Focus on the duplicates (i.e. two schemas with identical names selected... one based in a Visual Studio 12 folder and the other in a Visual Studio 14 folder, for example). – Triynko Feb 09 '17 at 19:29
  • 1
    Same problem with vs 2017 (vs 2015 was uninstalled), I had duplicate entries for DotNetConfig.xsd, removed the vs 2015 schema refrence and this fixed it. – apr Mar 21 '17 at 08:09
  • Just as an FYI...After you change an option, make sure to click a different row in order for the change to persist before clicking OK. – Jason Butera Apr 05 '17 at 13:29
7

I had this problem on a machine with different Visual Studio Versions and migrated projects. The schema cache (Menu Xml, Item Schemas...) shows double entries for RazorCustomSchema.xsd, EntityFrameworkConfig_6_1_0.xsd and DotNetConfig.xsd coming from the current (14.0) and from an older version (in my case 11.0).

Manual removing the old entries from the schema cache solved the problem, but I had to remove the old entries from each project.

I think this is a migration problem with the schema cache.

Dirk Brockhaus
  • 4,922
  • 3
  • 38
  • 47
5

On VS open your proyect
Go to XML menu
Select Schemas...
Find al file names named DotNetConfigXX.xsd, in my case

  • DotNetConfig45.xsd
  • DotNetConfig.xsd

on the use column set all of them on automatic.
This will cause only the correct file is used

sample

hope this helps

J. Chomel
  • 8,193
  • 15
  • 41
  • 69
user3247097
  • 55
  • 1
  • 5