157

I have a windows forms application written in VS2010 with C# and get the following errors in the app.config file:

Message 4   Could not find schema information for the attribute 'name'
Message 8   Could not find schema information for the attribute 'name'
Message 12  Could not find schema information for the attribute 'name'
Message 5   Could not find schema information for the attribute 'serializeAs'
Message 15  Could not find schema information for the element 'CCP_Utility.Settings1'
Message 2   Could not find schema information for the element 'CCP_Utility.Properties.Settings'
Message 3   Could not find schema information for the element 'setting'
Message 1   Could not find schema information for the element 'userSettings'
Message 6   Could not find schema information for the element 'value'

What do I have to change in the code to fix this issue? Where can I edit what's in CCP_Utility.Settings1 and CCP_Utility.Properties.Settings ?

Here's the app.config code:

<configuration>
<configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section name="CCP_Utility.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        <section name="CCP_Utility.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    </sectionGroup>
  </configSections>
<userSettings>
  <CCP_Utility.Properties.Settings>
    <setting name="SourceDir" serializeAs="String">
      <value />
    </setting>
    <setting name="TargetDir" serializeAs="String">
      <value />
    </setting>
    <setting name="CorpID" serializeAs="String">
      <value />
    </setting>
  </CCP_Utility.Properties.Settings>
    <CCP_Utility.Settings1>
        <setting name="sourceDir" serializeAs="String">
            <value />
        </setting>
        <setting name="targetDir" serializeAs="String">
            <value />
        </setting>
    </CCP_Utility.Settings1>

   </userSettings>
</configuration>
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Brian McCarthy
  • 4,658
  • 16
  • 49
  • 66
  • This looks like a dupe of this question: http://stackoverflow.com/questions/179927/how-to-resolve-could-not-find-schema-information-for-the-element-attribute-xxx. Check the answer by @user57433. – rsbarro Mar 14 '11 at 20:39
  • @rsbarro, Where is the EntLib configuration tool and DotNetConfig.xsd file located? – Brian McCarthy Mar 15 '11 at 13:55
  • Sorry, I didn't realize that user posted two answers to the question. I was referencing the second answer. That answer, while correct, was a little unclear so a provided a more detailed answer below. – rsbarro Mar 15 '11 at 14:12
  • 1
    Thanks, rsbarro! StingyJack's original question was limited to errors using enterprise library configuration sections, not simply any custom config section. – Lisa Jun 20 '11 at 05:28

10 Answers10

228

Quickest, easiest laziest way to solve the problem:

  1. Right-click on the project icon in Solution Explorer and choose "Properties".
  2. Go to the "Application" tab and choose an earlier .NET target framework.
  3. Save changes.
  4. Go to the "Application" tab and choose the initial .NET target framework.
  5. Save changes => problem solved!
Suncat2000
  • 966
  • 1
  • 12
  • 15
reexmonkey
  • 2,455
  • 1
  • 14
  • 9
  • 5
    This might not work on the first try. I needed to do it twice before it worked in VS 2013 Express. – H2ONaCl Apr 25 '14 at 14:55
  • Sadly no joy with VS2013 Ultimate. – Kev Apr 22 '15 at 11:05
  • if not works. be careful for nuget packages. (open up web.config>XML Menu>Add>yourProject\Packages\BlahLib\blah.xsd)add xsd files in xml schemas if any xsd file is published in your nuget packages. than do this trick. – Zen Of Kursat May 18 '15 at 17:04
  • this worked in the Enterprise 2015 RC trial on a vb.net win form – sipp Jul 02 '15 at 19:36
  • 25
    Worked for me in Visual Studio 2015. Would be nice if someone could explain why. – Jonathan Wood Oct 09 '15 at 20:23
  • 1
    Does not work for me in VS 2013 Professional. This workaround may be laziest but it's neither quick nor easy, simply because it has no effect. – datps Apr 18 '16 at 08:15
  • wonky. but it worked. changed. saved. changed back. saved. problem gone. VS2015 Update 2, .NET 4.6.0138 – Perry Tew Jun 18 '16 at 03:43
  • 6
    Didn't work, VS2015 update 2, .NET 4.5.2. It looks like it makes the messages go away, but then if you simply open up the XML file again, they come back. – Snoop Oct 10 '16 at 18:01
  • Worked for me too in Version 14.0.24720.00 Update 1. Only difference I had to upgrade the existing version from 4.5 to 4.5.1 after saving to older 4.0 version. – joym8 Jan 05 '17 at 17:41
  • With VS2017 Enterprise on following these steps left me with two entries in the schema list: DotNetConfig.xsd and DotNetConfig45.xsd, which in turn gave multiple warnings that types were already declared. DotNetConfig45.xsd will remove these messages (as advertised) but since the other schema: DotNetConfig.xsd cannot be deleted from the list, it gives the duplication of types warnings. That said, it's not a big deal, the messages are just an annoyance and are preferable to the warnings. I'm just leaving it as-is. – Ho Ho Ho Dec 06 '17 at 18:49
  • Errata:It seems to have only temporarily worked in VS 2019. I'm not sure what changed in my project, but I'm seeing this error again. – computercarguy Sep 25 '19 at 23:44
  • 1
    That worked thanks Or you can change the framework then put back the version you had – Zimo Oct 30 '20 at 20:37
181

UPDATE Sept 2015
This answer continues to get upvotes, so I'm going to leave it here since it seems to be helpful to some people, but please check out the other answers from @reexmonkey and @Pressacco first. They may provide better results.

ORIGINAL ANSWER
Give this a shot:

  1. In Visual Studio, open your app.config or web.config file.
  2. Go to the "XML" menu and select "Create Schema". This action should create a new file called "app.xsd" or "web.xsd".
  3. Save that file to your disk.
  4. Go back to your app.config or web.config and in the edit window, right click and select properties. From there, make sure the xsd you just generated is referenced in the Schemas property. If it's not there then add it.

That should cause those messages to disappear.

I saved my web.xsd in the root of my web folder (which might not be the best place for it, but just for demonstration purposes) and my Schemas property looks like this:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\xml\Schemas\DotNetConfig.xsd" "Web.xsd"

Matt
  • 25,467
  • 18
  • 120
  • 187
rsbarro
  • 27,021
  • 9
  • 71
  • 75
  • 11
    @rsbarro, Thanks your response! Why do you have 2 xsd files? I created the schema and came up with just 1 file- app.xsd which I saved to the root directory. The errors dissapeared but now i get a warning: "The global element 'configuration' has aleady been declared". Any idea on how to fix this? – Brian McCarthy Mar 15 '11 at 16:10
  • The DotNetConfig.xsd file was there by default. The Web.xsd was generated when I did "Create Schema". You could try this: clear the Schemas properly entirely, and then check if you have a DotNetConfig.xsd file at the location listed in the answer and if so, add that to the Schemas property. See what errors you get, and then try to regenerate the app.xsd. – rsbarro Mar 15 '11 at 16:45
  • @rsbarro, Thanks your response! I do have the file at C:\Program Files (x86)\Microsoft Visual Studio 10.0\xml\Schemas\DotNetConfig.xsd. How do I clear and add files to the schema's property? – Brian McCarthy Mar 15 '11 at 16:57
  • 2
    Just use the Properties dialog to select your schema or add another schema. When you are viewing the app.config, right click in the editor window and select Properties. You should see Schemas in the Property Editor control that pops up. Also, if you click the "..." button in Schemas it lets you select the schemas you want to use for your config file using a nice GUI. – rsbarro Mar 15 '11 at 17:08
  • @rsbarro, thanks for your response! How many schemas do I want to use? I added app.xsd schema which I saved to the properties folder and dotnetconfig.xsd which is under the visual studio 9.0 schemas folder. Is there anything else I shuold add? It has reduced my errors for schema but not completely for some reason... – Brian McCarthy Mar 16 '11 at 12:59
  • @Brian McCarthy, not sure. In my project I just have the dotnetconfig.xsd and the web.xsd, and I'm not seeing any warning messages for my web.config. If you're still seeing warnings messages though I wouldn't worry about it too much. They're more annoying than anything else. – rsbarro Mar 16 '11 at 14:44
  • This answer is one of the most useful in SO in my coding memory -- cheers! – Lisa Jun 20 '11 at 06:06
  • 3
    Thanks. This worked, but is there a good place I can read to understand WHY this happens? It seems like I just all of a sudden needed to generate a schema for my web.config after adding a lot of content for DotNetOpenAuth and then re-generating an edmx file from scratch. It makes sense in a "You changed a lot of things, so something got wonked." sort of way, but it would be helpful to know why the web.config file would spontaneously need a schema. – froggythefrog Jan 05 '13 at 05:49
  • 6
    When you generate your Web.xsd file, include just the schemas that you add in your web/app.config sections (user sections). Exclude all other that already in default schema or others .xsd included. – Pagotti Jul 11 '13 at 02:59
  • 1
    You can reference the default schemas, not need to create them manually. The default schemas are in: `C:\Program Files (x86)\Microsoft Visual Studio 11.0\xml\Schemas\1033`. You can reference multiple schemas, like `DotNetConfig.xsd`, `EntityFrameworkConfig_5_0_0.xsd` and `RazorCustomSchema.xsd` etc. Make sure to put double quotes around the paths, and separate multiple schemas by spaces. – Abel May 13 '14 at 16:59
  • 11
    NO NO NO!! This is not the "solution", since its not even a real problem. See and vote for @pressacco's answer. Also reexmonkey's answer works. Why is this answer getting so many positive votes? 1. Simply ignore! Close the app.config or web.config and compile you won't even see the messages. 2. Although no need to, solve by right clicking the .config properties correcting the path to the VS supplied XSD. (@pressacco's answer) 3. Or: change project settings DotNet version and back. Repeat twice. (reexmonkey's answer). May cause problems with package updates. – pashute Apr 29 '15 at 10:02
  • Seems like a tedious tedious compared to the below ones. – Jay Oct 11 '16 at 09:49
  • root cause analysis would be handy here. is MSDEV confused as to the location of the schema data and this "fix" causes it to relocate the original schema? Or is it looking at the new file. That's not clear to me. I'm getting the error today on a valid schema. It's also not clear if the error is coming from the MSBuild system or some error checking done by Visual Studio (2013 in my case), which would be MSDEV. – Ross Youngblood Mar 15 '17 at 14:56
  • Doing this makes the info messages go away, but instead I am **getting 2 additional warnings:** "Imported Schema for namespace 'urn:schemas-microsoft-com:asm.vs' was not resolved" and "The global element 'configuration' has already been declared." How to fix that? – Matt Oct 18 '17 at 13:17
22

An XSD is included with EntLib 5, and is installed in the Visual Studio schema directory. In my case, it could be found at:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\EnterpriseLibrary.Configuration.xsd

CONTEXT

  • Visual Studio 2010
  • Enterprise Library 5

STEPS TO REMOVE THE WARNINGS

  1. open app.config in your Visual Studio project
  2. right click in the XML Document editor, select "Properties"
  3. add the fully qualified path to the "EnterpriseLibrary.Configuration.xsd"

ASIDE

It is worth repeating that these "Error List" "Messages" ("Could not find schema information for the element") are only visible when you open the app.config file. If you "Close All Documents" and compile... no messages will be reported.

Janis S.
  • 2,526
  • 22
  • 32
Pressacco
  • 2,815
  • 2
  • 26
  • 45
  • Sorry I might be missing something, what do you mean by "add the path the fully qualified path to the "EnterpriseLibrary.Configuration.xsd"" – Paul C Jun 07 '12 at 13:11
  • 1
    By fully qualify path I meant: use an absolute path. For example `C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\EnterpriseLibrary.Configuration.xsd`. On a Windows operating system, a relative path can include .\ and ..\ characters. – Pressacco Jun 14 '12 at 13:45
  • A related posting can be found at: [link](http://stackoverflow.com/q/179927/949681) – Pressacco Jun 14 '12 at 13:51
  • 9
    Is the EnterpriseLibrary.Configuration.xsd missing in Visual Studio 2015? – Luke Nov 12 '15 at 10:36
  • 1
    Thank you @Taegost, this did it for me too. (My problem, code analysis custom dictionary under VS2013, was slightly different than stated, but same symptoms). Nothing else I tried worked and this was driving me crazy. When I had the dictionary open in the editor, it appears that the code analysis tool wasn't even using it due to these errors! – sn00gan Jul 22 '19 at 20:23
2

This error occurs when your project references out of date schemas. Use Visual Studio to generate new ones.

In Visual Studio, do the following:

  1. Open your app.config or web.config file.
  2. Go to the XML menu and select Create Schema.

This will trigger app#.xsd (Windows app) or web#.xsd (Website) file(s) to generate.

  1. Save the newly generated xsd file(s) to the root of the project.
    • Open up your App.config or web.config file, right-click in the text-editor and select properties and click the ... button next to the value for Schemas.
    • Add the newly generated xsd file(s) using the Add button.
    • Click OK

The Could not find schema information for the attribute/element error(s) should now be resolved.

WonderWorker
  • 8,539
  • 4
  • 63
  • 74
1

I found that there was a syntax error in the related module and it wasn't compiling - the compiler didn't tell me that though. Just gave me the error regarding the app.config stuff. VS2010. Once I had fixed the syntax error, all was good.

flobadob
  • 2,804
  • 2
  • 22
  • 23
1

Simple: In Visual Studio Report designer
1. Open the report in design mode and delete the dataset from the RDLC File
2. Open solution Explorer and delete the actual (corrupted) XSD file
3. Add the dataset back to the RDLC file.
4. The above procedure will create the new XSD file.
5. More detailed is below.

In Visual Studio, Open your RDLC file Report in Design mode. Click on the report and then Select View and then Report Data from the top line menu. Select Datasets and then Right Click and delete the dataset from the report. Next Open Solution Explorer, if it is not already open in your Visual Studio. Locate the XSD file (It should be the same name as the dataset you just deleted from the report). Now go back and right click again on the report data Datasets, and select Add Dataset . This will create a new XSD file and write the dataset properties to the report. Now your error message will be gone and any missing data will now appear in your reports.

Grambot
  • 4,370
  • 5
  • 28
  • 43
Greg T.
  • 11
  • 1
0

When this happened to me (out of nowhere) I was about to dive into the top answer above, and then I figured I'd close the project, close Visual Studio, and then re-open everything. Problem solved. VS bug?

Rockin Raul
  • 115
  • 9
0

I had this in VS 2012 where the "Section name" had been changed in a project, and I fixed it by deleting "app.config" in the project, then right-clicking on the project in the "Solution Explorer", selecting "Properties", then "Settings", then making a change to one of the settings, saving, and re-building. This created a new app.config with the correct information.

Davy C
  • 639
  • 5
  • 16
0

In my case I had an ambiguous reference in my code. I restarted Visual Studio and was able to see the error message. When I resolved this the other error disappeared.

Sofia Khwaja
  • 1,909
  • 3
  • 17
  • 20
-1

Most of what I write has already been covered by Pressacco, but this is specific to SpecFlow.

I was getting this message for the <specFlow> element and therefore I added a specflow.xsd file to the solution this answer (with some modifications to allow for the <plugins> element).

Thereafter I (like Pressacco), right clicked within the file buffer of app.config and selected properties, and within Schemas, I added "specflow.xsd" to the end. The entirety of Schemas now reads:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\1033\DotNetConfig.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\EntityFrameworkConfig_6_1_0.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\RazorCustomSchema.xsd" "specflow.xsd"
Community
  • 1
  • 1
Tahir Hassan
  • 5,715
  • 6
  • 45
  • 65