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

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

问题描述

我有一个用 C# 用 VS2010 编写的 windows 窗体应用程序,在 app.config 文件中出现以下错误:

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'

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

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 ?

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

推荐答案

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

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.

原答案
试一试:

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

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

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视觉工作室10.0xmlSchemasDotNetConfig.xsd" "Web.xsd"

"C:Program Files (x86)Microsoft Visual Studio 10.0xmlSchemasDotNetConfig.xsd" "Web.xsd"

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

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