如何修复错误:“无法找到属性/元素的模式信息”通过创建模式 [英] How to fix Error: "Could not find schema information for the attribute/element" by creating schema

查看:196
本文介绍了如何修复错误:“无法找到属性/元素的模式信息”通过创建模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b $

 消息4找不到属性'name'的模式信息
消息8找不到属性'name'的模式信息
消息12找不到属性'name'的模式信息
消息5找不到属性'serializeAs'的模式信息
消息15无法找到元素CCP_Utility的模式信息.Settings1'
消息2找不到元素'CCP_Utility.Properties.Settings'
的模式信息消息3找不到元素'设置'的模式信息
消息1找不到元素'userSettings'的模式信息
消息6无法找到元素'value'的模式信息

我必须改变代码来解决这个问题吗?在哪里可以修改 CCP_Utility.Settings1 CCP_Utility.Properties.Settings



这里是 app.config 代码:

 <结构> 
< configSections>
< sectionGroup name =userSettingstype =System.Configuration.UserSettingsGroup,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089>
< section name =CCP_Utility.Properties.Settingstype =System.Configuration.ClientSettingsSection,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089allowExeDefinition =MachineToLocalUserrequirePermission =false />
< section name =CCP_Utility.Settings1type =System.Configuration.ClientSettingsSection,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089allowExeDefinition =MachineToLocalUserrequirePermission =false/ >
< / sectionGroup>
< / configSections>
< userSettings>
< CCP_Utility.Properties.Settings>
< setting name =SourceDirserializeAs =String>
< value />
< / setting>
< setting name =TargetDirserializeAs =String>
< value />
< / setting>
< setting name =CorpIDserializeAs =String>
< value />
< / setting>
< /CCP_Utility.Properties.Settings>
< CCP_Utility.Settings1>
< setting name =sourceDirserializeAs =String>
< value />
< / setting>
< setting name =targetDirserializeAs =String>
< value />
< / setting>
< /CCP_Utility.Settings1>

< / userSettings>
< / configuration>


解决方案

2015年9月更新 br />
这个答案继续得到upvote,所以我要离开它,因为它似乎对一些人有帮助,但请查看其他答案从@reexmonkey @Pressacco 。他们可能会提供更好的结果。



原始答案

给这个镜头:


  1. 在Visual Studio中,打开你的app.config或web.config文件。

  2. 转到XML菜单,选择创建模式。此操作应该创建一个名为app.xsd或web.xsd的新文件。

  3. 将该文件保存到磁盘。

  4. 转到返回到您的app.config或web.config,并在编辑窗口中,右键单击并选择属性。从那里,确保您刚才生成的xsd在Schemas属性中引用。如果不在那里添加它。

这应该会导致消息消失。



我保存了我的网页.xsd在我的网络文件夹的根目录(这可能不是最好的地方,但只是为了演示目的),我的Schemas属性如下所示:


C:\程序文件(x86)\Microsoft
Visual Studio
10.0\xml\Schemas\DotNetConfig.xsdWeb.xsd



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>

解决方案

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"

这篇关于如何修复错误:“无法找到属性/元素的模式信息”通过创建模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆