如何修复错误:“无法找到属性/元素的架构信息”通过创建模式
我有一个使用 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.Settings1
和 CCP_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
解决问题的最快、最简单、最懒的方法:
Quickest, easiest laziest way to solve the problem:
2015 年 9 月更新
这个答案继续获得投票,所以我将把它留在这里,因为它似乎对某些人有帮助,但请查看 @reexmonkey 和 @Pressacco 首先。他们可能会提供更好的结果。
原始答案
尝试一下:
这应该会导致这些消息消失。
我将 web.xsd 保存在 Web 文件夹的根目录中(这可能不是最佳位置,但仅用于演示目的),我的 Schemas 属性如下所示:
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:
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:
XSD 包含在 EntLib 5 中,并安装在 Visual Studio 架构目录中。就我而言,可以在以下位置找到它:
CONTEXT
删除警告的 5 个步骤
旁白
值得重复的是,这些“错误列表”“消息”(“无法找到该元素的架构信息”)仅在打开 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:
CONTEXT
STEPS TO REMOVE THE WARNINGS
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.
当您的项目引用过时的架构时,会出现此错误。使用 Visual Studio 生成新的。
在 Visual Studio 中,执行以下操作:
app.config
或web.config
文件。XML
菜单并选择创建架构
。App.config
或web.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:
app.config
orweb.config
file.XML
menu and selectCreate Schema
.App.config
orweb.config
file, right-click in the text-editor and select properties and click the...
button next to the value for Schemas.Add
button.OK
The Could not find schema information for the attribute/element error(s) should now be resolved.
我发现相关模块中存在语法错误,并且无法编译 - 但编译器没有告诉我这一点。刚刚给了我有关 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.
简单:在 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.
当这种情况发生在我身上时(不知从何而来),我正要深入研究上面的最佳答案,然后我想我应该关闭该项目,关闭 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?
我在 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.
就我而言,我的代码中有一个不明确的引用。我重新启动 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.
我写的大部分内容已经由 Pressacco 涵盖,但这是特定于 SpecFlow 的。
我收到了
元素的消息,因此我向解决方案中添加了specflow.xsd
文件 这个答案(进行一些修改以允许
元素)。此后,我(像 Pressacco 一样)在
app.config
的文件缓冲区和选定的属性中单击鼠标右键,并在Schemas
中添加“specflow.xsd”< /code> 到最后。整个
Schemas
现在显示为: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 aspecflow.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 withinSchemas
, I added"specflow.xsd"
to the end. The entirety ofSchemas
now reads: