How to fix Error: "Could not find schema information for the attribute/element" by creating schema
Asked Answered
I

10

158

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>
Inspirational answered 14/3, 2011 at 19:32 Comment(4)
This looks like a dupe of this question: #180427. Check the answer by @user57433.Sheathbill
@rsbarro, Where is the EntLib configuration tool and DotNetConfig.xsd file located?Inspirational
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.Sheathbill
Thanks, rsbarro! StingyJack's original question was limited to errors using enterprise library configuration sections, not simply any custom config section.Frigorific
S
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"

Sheathbill answered 15/3, 2011 at 14:10 Comment(14)
@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?Inspirational
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.Sheathbill
@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?Inspirational
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.Sheathbill
@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...Inspirational
@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.Sheathbill
This answer is one of the most useful in SO in my coding memory -- cheers!Frigorific
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.Expressive
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.Zermatt
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.Marylandmarylee
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.Aftonag
Seems like a tedious tedious compared to the below ones.Asbury
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.Culley
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?Generate
S
229

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!
Sewage answered 19/2, 2013 at 19:20 Comment(12)
This might not work on the first try. I needed to do it twice before it worked in VS 2013 Express.Gemma
Sadly no joy with VS2013 Ultimate.Duffer
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.Scibert
this worked in the Enterprise 2015 RC trial on a vb.net win formElga
Worked for me in Visual Studio 2015. Would be nice if someone could explain why.Reckless
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.Lucrative
wonky. but it worked. changed. saved. changed back. saved. problem gone. VS2015 Update 2, .NET 4.6.0138Wellfound
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.Sharpset
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.Moia
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.Meshach
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.Neibart
That worked thanks Or you can change the framework then put back the version you hadAshling
S
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"

Sheathbill answered 15/3, 2011 at 14:10 Comment(14)
@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?Inspirational
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.Sheathbill
@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?Inspirational
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.Sheathbill
@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...Inspirational
@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.Sheathbill
This answer is one of the most useful in SO in my coding memory -- cheers!Frigorific
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.Expressive
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.Zermatt
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.Marylandmarylee
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.Aftonag
Seems like a tedious tedious compared to the below ones.Asbury
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.Culley
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?Generate
H
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.

Hardheaded answered 22/9, 2011 at 15:40 Comment(5)
Sorry I might be missing something, what do you mean by "add the path the fully qualified path to the "EnterpriseLibrary.Configuration.xsd""Stressful
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.Hardheaded
A related posting can be found at: linkHardheaded
Is the EnterpriseLibrary.Configuration.xsd missing in Visual Studio 2015?Millar
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!Sanguine
F
3

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.

Flathead answered 15/5, 2017 at 13:54 Comment(0)
T
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.

Trevatrevah answered 11/1, 2015 at 15:51 Comment(0)
C
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.

Cannon answered 28/7, 2016 at 13:55 Comment(0)
O
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?

Organization answered 16/2, 2017 at 17:16 Comment(1)
Overkill. Closing the App.config file editor within VS is enough. VS bug, maybe.Cobalt
G
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.

Grundy answered 17/3, 2017 at 10:17 Comment(0)
S
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.

Septenary answered 17/4, 2018 at 11:54 Comment(0)
T
-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"
Trollop answered 3/2, 2016 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.