9

This warning generated from my app.config file is driving me crazy and I have been searching without getting any real answer as to why this is the case. Here is the code.

enter image description here

Any help would be greatly appreciated

Kefash
  • 523
  • 2
  • 10
  • 24
  • I think you need to look http://stackoverflow.com/questions/12523996/the-configuration-element-is-not-declared – Jayesh Bhoi Aug 27 '14 at 04:45
  • thanks but that question wasn't answered either. I did however looked at and tried the suggestions – Kefash Aug 27 '14 at 05:21
  • You mean app.config? – Steen Tøttrup Aug 27 '14 at 05:23
  • @SteenT Yeah, that what I meant. Must be too tired – Kefash Aug 27 '14 at 05:25
  • It can't find the schema for some reason. One thread recommends changing the framework version in properties and then changing it back again (for 2012/13). http://stackoverflow.com/questions/5303476/how-to-fix-error-could-not-find-schema-information-for-the-attribute-element – Andrew Aug 27 '14 at 06:15

3 Answers3

16

I fixed the problem for VS2013 and .NET 4.6 targeting projects by editing C:\Program Files (x86)\Microsoft Visual Studio 12.0\Xml\Schemas\catalog.xml.

I modified existing line:

<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd"   condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or $TargetFrameworkMoniker = ''" />

to

<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd"   condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.6')" />

Closed and reopened VS2013 and intellisense in both app.config and web.config files started to work again (with .NET 4.6 targeting projects).

Meeting Attender
  • 826
  • 11
  • 17
  • 2
    For VS2017 Enterprise path of the catalog.xml is C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Xml\Schemas\catalog.xml – Meeting Attender May 26 '17 at 21:17
  • Visual Studio 2017 has the same problem with .NETFramework 4.7. This solution, with an additional "or starts-with .... v4.7')"-clause, solves that problem. See @MeetingAttender's comment for the location of catalog.xml – Kasper van den Berg Jul 12 '17 at 07:44
13

From the main menu in VS, choose XML > Schemas... (must have XML file open in IDE to see the XML menu item). In the window that pops up, find the entry for DotNetConfig.xsd (should be first item), and select the checkmark in the Use column for that entry. Then click OK.

softwaredev
  • 451
  • 6
  • 7
1

I had the same problem, this solved it:

From the Visual Studio menu, click XML>Schemas...

Look for DotNetConfig.xsd

Make sure you check 'use this schema'

And 'Ok'

ascripter
  • 5,665
  • 12
  • 45
  • 68
Josef Ek
  • 11
  • 1