如何修复错误:"未能找到属性/元素&QUOT架构信息;通过创建模式 [英] How to fix Error: "Could not find schema information for the attribute/element" by creating schema

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

问题描述

我有一个Windows窗体应用程序用VS2010编写C#和获得的的app.config 文件以下错误:

消息4找不到属性名称的架构信息
第8条消息未能找到属性名称的架构信息
消息12未能找到属性名称的架构信息
消息5未能找到属性架构信息'serializeAs
消息15未能找到元素CCP_Utility.Settings1的架构信息
消息2找不到架构信息元素'CCP_Utility.Properties.Settings
消息3未能找到元素架构信息'设置'
消息1未能找到元素架构信息'userSettings
消息6未能找到元素价值的架构信息

我有什么在code,以解决此问题的改变?我在哪里可以编辑什么是在 CCP_Utility.Settings1 CCP_Utility.Properties.Settings

这里的的app.config code:

<结构>
< configSections>
    < sectionGroup NAME =userSettingsTYPE =System.Configuration.UserSettingsGroup,系统,版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089>
        <节名称=CCP_Utility.Properties.SettingsTYPE =System.Configuration.ClientSettingsSection,系统,版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089allowExeDefinition =MachineToLocalUserrequirePermission =FALSE/>
        <节名称=CCP_Utility.Settings1TYPE =System.Configuration.ClientSettingsSection,系统,版本= 2.0.0.0,文化=中性公钥= b77a5c561934e089allowExeDefinition =MachineToLocalUserrequirePermission =FALSE/>
    < / sectionGroup>
  < / configSections>
< userSettings>
  < CCP_Utility.Properties.Settings>
    <设定名=SourceDirserializeAs =字符串>
      <价值/>
    < /设置>
    <设定名=TARGETDIRserializeAs =字符串>
      <价值/>
    < /设置>
    <设定名=CorpIDserializeAs =字符串>
      <价值/>
    < /设置>
  < /CCP_Utility.Properties.Settings>
    < CCP_Utility.Settings1>
        <设定名=sourceDirserializeAs =字符串>
            <价值/>
        < /设置>
        <设定名=TARGETDIRserializeAs =字符串>
            <价值/>
        < /设置>
    < /CCP_Utility.Settings1>   < / userSettings>
< /结构>


解决方案

更新2015年9月

这个答案将继续得到upvotes,所以我要去,因为它似乎是有帮助的一些人离开这里,但请首先从@reexmonkey和@ pressacco检查了其他的答案。他们可能会提供更好的结果。

原来的答案

给这一个镜头:


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

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

  3. 的文件保存到磁盘。

  4. 返回到您的app.config或web.config文件,并在编辑窗口后,右键单击并选择属性。从那里,请确保您刚刚生成的XSD的架构特性被引用。如果它不存在,然后添加它。

这应该引起那些消息消失。

我救了我的web.xsd在我的Web文件夹的根目录下(这可能不是它最好的地方,只是为了演示)和我的架构特性如下:


  

C:\\ Program Files文件(x86)的\\微软
  视觉工作室
  10.0 \\ XML \\架构\\ 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"

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

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