且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-01-01 15:02:41

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"