如何修复错误:“无法找到属性/元素的架构信息”通过创建模式

发布于 2024-10-22 01:47:23 字数 2588 浏览 4 评论 0原文

我有一个使用 C# 在 VS2010 中编写的 Windows 窗体应用程序,并在 app.config 文件中收到以下错误:

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'

我必须在代码中更改哪些内容才能解决此问题?在哪里可以编辑 CCP_Utility.Settings1CCP_Utility.Properties.Settings 中的内容?

这是 app.config 代码:

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

零度° 2024-10-29 01:47:23

解决问题的最快、最简单、最懒的方法:

  1. 右键单击“解决方案资源管理器”中的项目图标,然后选择“属性”。
  2. 转到“应用程序”选项卡并选择早期的 .NET 目标框架。
  3. 保存更改。
  4. 转到“应用程序”选项卡并选择初始 .NET 目标框架。
  5. 保存更改=>问题解决了!

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!
始终不够 2024-10-29 01:47:23

2015 年 9 月更新
这个答案继续获得投票,所以我将把它留在这里,因为它似乎对某些人有帮助,但请查看 @reexmonkey@Pressacco 首先。他们可能会提供更好的结果。

原始答案
尝试一下:

  1. 在 Visual Studio 中,打开 app.config 或 web.config 文件。
  2. 转到“XML”菜单并选择“创建架构”。此操作应创建一个名为“app.xsd”或“web.xsd”的新文件。
  3. 将该文件保存到您的磁盘上。
  4. 返回到 app.config 或 web.config,然后在编辑窗口中右键单击并选择属性。从那里,确保您刚刚生成的 xsd 在 Schemas 属性中被引用。如果不存在,则添加它。

这应该会导致这些消息消失。

我将 web.xsd 保存在 Web 文件夹的根目录中(这可能不是最佳位置,但仅用于演示目的),我的 Schemas 属性如下所示:

“C:\Program Files (x86)\Microsoft
视觉工作室
10.0\xml\Schemas\DotNetConfig.xsd" "Web.xsd"

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"

若水微香 2024-10-29 01:47:23

XSD 包含在 EntLib 5 中,并安装在 Visual Studio 架构目录中。就我而言,可以在以下位置找到它:

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

CONTEXT

  • Visual Studio 2010
  • Enterprise Library

删除警告的 5 个步骤

  1. 在 Visual Studio 项目中打开 app.config
  2. ,右键单击 XML 文档编辑器,选择“属性”,
  3. 将完全限定路径添加到“EnterpriseLibrary.Configuration.xsd”

旁白

值得重复的是,这些“错误列表”“消息”(“无法找到该元素的架构信息”)仅在打开 app.config 文件时可见。如果您“关闭所有文档”并编译...将不会报告任何消息。

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.

烟─花易冷 2024-10-29 01:47:23

当您的项目引用过时的架构时,会出现此错误。使用 Visual Studio 生成新的。

在 Visual Studio 中,执行以下操作:

  1. 打开 app.configweb.config 文件。
  2. 转到 XML 菜单并选择创建架构

这将触发生成 app#.xsd(Windows 应用程序)或 web#.xsd(网站)文件。

  1. 将新生成的 xsd 文件保存到项目的根目录。
    • 打开您的 App.configweb.config 文件,在文本编辑器中右键单击并选择属性,然后单击 ...<模式值旁边的 /code> 按钮。
    • 使用添加按钮添加新生成的xsd文件。
    • 点击确定

现在,找不到属性/元素的架构信息错误应该已得到解决。

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.

若有似无的小暗淡 2024-10-29 01:47:23

我发现相关模块中存在语法错误,并且无法编译 - 但编译器没有告诉我这一点。刚刚给了我有关 app.config 内容的错误。 VS2010。一旦我修复了语法错误,一切都很好。

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.

小傻瓜 2024-10-29 01:47:23

简单:在 Visual Studio 报表设计器中
1. 在设计模式下打开报表并从RDLC文件中删除数据集
2. 打开解决方案资源管理器并删除实际(损坏的)XSD 文件
3. 将数据集添加回 RDLC 文件。
4. 上述过程将创建新的 XSD 文件。
5. 更详细的内容如下。

在 Visual Studio 中,在设计模式下打开 RDLC 文件报告。单击报告,然后从顶行菜单中选择查看,然后选择报告数据。选择数据集,然后右键单击并从报告中删除数据集。接下来打开解决方案资源管理器(如果尚未在 Visual Studio 中打开)。找到 XSD 文件(它应该与您刚刚从报告中删除的数据集同名)。现在返回并再次右键单击报告数据 Datasets,然后选择 Add Dataset 。这将创建一个新的 XSD 文件并将数据集属性写入报告。现在您的错误消息将消失,所有丢失的数据现在将显示在您的报告中。

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.

一萌ing 2024-10-29 01:47:23

当这种情况发生在我身上时(不知从何而来),我正要深入研究上面的最佳答案,然后我想我应该关闭该项目,关闭 Visual Studio,然后重新打开所有内容。问题解决了。 VS错误?

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?

上课铃就是安魂曲 2024-10-29 01:47:23

我在 VS 2012 中遇到了这个问题,其中项目中的“部分名称”已更改,我通过删除项目中的“app.config”来修复它,然后右键单击“解决方案资源管理器”中的项目,选择“ “属性”,然后“设置”,然后更改其中一项设置,保存并重新构建。这将创建一个包含正确信息的新 app.config。

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.

成熟的代价 2024-10-29 01:47:23

就我而言,我的代码中有一个不明确的引用。我重新启动 Visual Studio 并能够看到错误消息。当我解决这个问题时,另一个错误就消失了。

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.

一萌ing 2024-10-29 01:47:23

我写的大部分内容已经由 Pressacco 涵盖,但这是特定于 SpecFlow 的。

我收到了 元素的消息,因此我向解决方案中添加了 specflow.xsd 文件 这个答案(进行一些修改以允许 元素)。

此后,我(像 Pressacco 一样)在 app.config 的文件缓冲区和选定的属性中单击鼠标右键,并在 Schemas 中添加 “specflow.xsd”< /code> 到最后。整个 Schemas 现在显示为:

"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"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文