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

时间:2022-10-13 17:04:59

I have a windows forms application written in VS2010 with C# and get the following errors in the app.config file:

我在VS2010中使用c#编写了一个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'

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 ?

为了解决这个问题,我需要修改代码什么?在哪里可以编辑CCP_Utility中的内容。Settings1 CCP_Utility.Properties。设置?

Here's the app.config code:

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

10 个解决方案

#1


150  

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.

2015年9月,这个答案继续得到支持,所以我打算把它留在这里,因为它似乎对一些人很有帮助,但是请先看看@reexmonkey和@Pressacco的其他答案。他们可能会提供更好的结果。

ORIGINAL ANSWER
Give this a shot:

原来的答案是这样的:

  1. In Visual Studio, open your app.config or web.config file.
  2. 在Visual Studio中,打开app.config或web。配置文件。
  3. Go to the "XML" menu and select "Create Schema". This action should create a new file called "app.xsd" or "web.xsd".
  4. 进入“XML”菜单,选择“创建模式”。该操作应该创建一个名为“app.xsd”或“web.xsd”的新文件。
  5. Save that file to your disk.
  6. 将该文件保存到磁盘。
  7. 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.
  8. 回到你的app.config或web。配置和编辑窗口,右击和选择属性。从那里,确保您刚刚生成的xsd在模式属性中被引用。如果没有,就把它加进去。

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:

我救了我的网页。在我的web文件夹的根目录(可能不是最好的地方,但只是为了演示),我的模式属性是这样的:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\xml\Schemas\DotNetConfig.xsd" "Web.xsd"

C:\程序文件(x86)\微软Visual Studio 10.0\xml\Schemas\DotNetConfig。xsd Web.xsd”

#2


187  

Quickest, easiest laziest way to solve the problem:

最快最简单的解决方法:

  1. Right-click on the project icon in Solution Explorer and choose "Properties".
  2. 右键单击解决方案资源管理器中的项目图标,并选择“属性”。
  3. Go to the "Application" tab and choose an earlier .NET target framework.
  4. 转到“应用程序”选项卡,选择较早的。net目标框架。
  5. Save changes.
  6. 保存更改。
  7. Go to the "Application" tab and choose the initial .NET target framework.
  8. 转到“应用程序”选项卡,选择初始的。net目标框架。
  9. Save changes => problem solved!
  10. 保存更改=>问题解决!

#3


20  

An XSD is included with EntLib 5, and is installed in the Visual Studio schema directory. In my case, it could be found at:

一个XSD包含在EntLib 5中,并安装在Visual Studio模式目录中。在我的案例中,它可以在:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\EnterpriseLibrary.Configuration.xsd

CONTEXT

  • Visual Studio 2010
  • Visual Studio 2010
  • Enterprise Library 5
  • 企业库5

STEPS TO REMOVE THE WARNINGS

  1. open app.config in your Visual Studio project
  2. 在Visual Studio项目中打开app.config。
  3. right click in the XML Document editor, select "Properties"
  4. 右键单击XML文档编辑器,选择“属性”
  5. add the fully qualified path to the "EnterpriseLibrary.Configuration.xsd"
  6. 将完全限定的路径添加到“EnterpriseLibrary.Configuration.xsd”中。

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.

值得重复的是,当您打开app.config文件时,这些“错误列表”“消息”(“无法找到元素的模式信息”)仅是可见的。如果您“关闭所有文档”并编译…没有消息将被报告。

#4


1  

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.

我发现在相关的模块中有一个语法错误,它没有编译——但是编译器没有告诉我。只是给了我关于app.config的错误。VS2010。一旦我修正了语法错误,一切都很好。

#5


1  

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.

简单:在Visual Studio报表设计器1中。在设计模式下打开报告,并从RDLC文件2中删除数据集。打开解决方案资源管理器并删除实际(损坏的)XSD文件3。将数据集添加到RDLC文件中。4所示。上面的过程将创建新的XSD文件。5。更详细的如下。

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中,在设计模式下打开RDLC文件报告。单击该报告,然后选择视图,然后从顶部行菜单中报告数据。选择数据集,然后右击并从报告中删除数据集。下一个打开的解决方案资源管理器,如果它还没有在您的Visual Studio中打开。定位XSD文件(它应该与您刚刚从报告中删除的数据集同名)。现在返回并右击报告数据集,并选择Add Dataset。这将创建一个新的XSD文件,并将数据集属性写入报告。现在您的错误消息将丢失,任何丢失的数据将出现在您的报告中。

#6


0  

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?

当这件事发生在我身上(不知从哪里)时,我就想深入到上面的答案,然后我想我将关闭这个项目,关闭Visual Studio,然后重新打开一切。问题解决了。和错误吗?

#7


0  

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.

我在VS 2012”栏目名称”已经改变了在一个项目中,我固定它通过删除“app.config”项目,然后右键单击项目在“解决方案资源管理器”中,选择“属性”,然后“设置”,然后做出改变的一个设置,保存和重建。这就创建了一个带有正确信息的新app.config。

#8


0  

This error occurs when your project references out of date schemas. Use Visual Studio to generate new ones.

当您的项目引用过时模式时,会出现此错误。使用Visual Studio生成新的。

In Visual Studio, do the following:

在Visual Studio中,执行以下操作:

  1. Open your app.config or web.config file.
  2. 打开您的app.config或web。配置文件。
  3. Go to the XML menu and select Create Schema.
  4. 转到XML菜单并选择Create Schema。

This will trigger app#.xsd (Windows app) or web#.xsd (Website) file(s) to generate.

这将触发应用#。xsd (Windows应用程序)或web#。生成的xsd(网站)文件。

  1. Save the newly generated xsd file(s) to the root of the project.
    • Open up your App.config or web.config file, right-click in the text-editor and select properties and click the ... button next to the value for Schemas.
    • 打开您的App.config或web。配置文件,在文本编辑器中右键单击并选择properties并单击…在模式值旁边的按钮。
    • Add the newly generated xsd file(s) using the Add button.
    • 使用Add按钮添加新生成的xsd文件。
    • Click OK
    • 单击OK
  2. 将新生成的xsd文件保存到项目的根目录中。打开您的App.config或web。配置文件,在文本编辑器中右键单击并选择properties并单击…在模式值旁边的按钮。使用Add按钮添加新生成的xsd文件。单击OK

The Could not find schema information for the attribute/element error(s) should now be resolved.

不能为属性/元素错误找到模式信息,现在应该解决了。

#9


0  

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.

在我的例子中,我的代码中有一个模糊的引用。我重新启动Visual Studio并能够看到错误消息。当我解决这个问题时,另一个错误就消失了。

#10


-1  

Most of what I write has already been covered by Pressacco, but this is specific to SpecFlow.

我写的大部分内容已经被Pressacco所覆盖,但这是特定于SpecFlow的。

I was getting this message for the <specFlow> element and therefore I added a specflow.xsd file to the solution this answer (with some modifications to allow for the <plugins> element).

我为 元素获取这个消息,因此添加了一个specFlow。xsd文件到解决方案的这个答案(有一些修改允许 元素)。

Thereafter I (like Pressacco), right clicked within the file buffer of app.config and selected properties, and within Schemas, I added "specflow.xsd" to the end. The entirety of Schemas now reads:

之后,我(像Pressacco一样)在app.config和selected属性的文件缓冲区中右键单击,并在模式中添加“specflow”。xsd”结束。现在,模式的全部内容如下:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\1033\DotNetConfig.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\EntityFrameworkConfig_6_1_0.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\RazorCustomSchema.xsd" "specflow.xsd"

#1


150  

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.

2015年9月,这个答案继续得到支持,所以我打算把它留在这里,因为它似乎对一些人很有帮助,但是请先看看@reexmonkey和@Pressacco的其他答案。他们可能会提供更好的结果。

ORIGINAL ANSWER
Give this a shot:

原来的答案是这样的:

  1. In Visual Studio, open your app.config or web.config file.
  2. 在Visual Studio中,打开app.config或web。配置文件。
  3. Go to the "XML" menu and select "Create Schema". This action should create a new file called "app.xsd" or "web.xsd".
  4. 进入“XML”菜单,选择“创建模式”。该操作应该创建一个名为“app.xsd”或“web.xsd”的新文件。
  5. Save that file to your disk.
  6. 将该文件保存到磁盘。
  7. 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.
  8. 回到你的app.config或web。配置和编辑窗口,右击和选择属性。从那里,确保您刚刚生成的xsd在模式属性中被引用。如果没有,就把它加进去。

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:

我救了我的网页。在我的web文件夹的根目录(可能不是最好的地方,但只是为了演示),我的模式属性是这样的:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\xml\Schemas\DotNetConfig.xsd" "Web.xsd"

C:\程序文件(x86)\微软Visual Studio 10.0\xml\Schemas\DotNetConfig。xsd Web.xsd”

#2


187  

Quickest, easiest laziest way to solve the problem:

最快最简单的解决方法:

  1. Right-click on the project icon in Solution Explorer and choose "Properties".
  2. 右键单击解决方案资源管理器中的项目图标,并选择“属性”。
  3. Go to the "Application" tab and choose an earlier .NET target framework.
  4. 转到“应用程序”选项卡,选择较早的。net目标框架。
  5. Save changes.
  6. 保存更改。
  7. Go to the "Application" tab and choose the initial .NET target framework.
  8. 转到“应用程序”选项卡,选择初始的。net目标框架。
  9. Save changes => problem solved!
  10. 保存更改=>问题解决!

#3


20  

An XSD is included with EntLib 5, and is installed in the Visual Studio schema directory. In my case, it could be found at:

一个XSD包含在EntLib 5中,并安装在Visual Studio模式目录中。在我的案例中,它可以在:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\EnterpriseLibrary.Configuration.xsd

CONTEXT

  • Visual Studio 2010
  • Visual Studio 2010
  • Enterprise Library 5
  • 企业库5

STEPS TO REMOVE THE WARNINGS

  1. open app.config in your Visual Studio project
  2. 在Visual Studio项目中打开app.config。
  3. right click in the XML Document editor, select "Properties"
  4. 右键单击XML文档编辑器,选择“属性”
  5. add the fully qualified path to the "EnterpriseLibrary.Configuration.xsd"
  6. 将完全限定的路径添加到“EnterpriseLibrary.Configuration.xsd”中。

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.

值得重复的是,当您打开app.config文件时,这些“错误列表”“消息”(“无法找到元素的模式信息”)仅是可见的。如果您“关闭所有文档”并编译…没有消息将被报告。

#4


1  

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.

我发现在相关的模块中有一个语法错误,它没有编译——但是编译器没有告诉我。只是给了我关于app.config的错误。VS2010。一旦我修正了语法错误,一切都很好。

#5


1  

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.

简单:在Visual Studio报表设计器1中。在设计模式下打开报告,并从RDLC文件2中删除数据集。打开解决方案资源管理器并删除实际(损坏的)XSD文件3。将数据集添加到RDLC文件中。4所示。上面的过程将创建新的XSD文件。5。更详细的如下。

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中,在设计模式下打开RDLC文件报告。单击该报告,然后选择视图,然后从顶部行菜单中报告数据。选择数据集,然后右击并从报告中删除数据集。下一个打开的解决方案资源管理器,如果它还没有在您的Visual Studio中打开。定位XSD文件(它应该与您刚刚从报告中删除的数据集同名)。现在返回并右击报告数据集,并选择Add Dataset。这将创建一个新的XSD文件,并将数据集属性写入报告。现在您的错误消息将丢失,任何丢失的数据将出现在您的报告中。

#6


0  

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?

当这件事发生在我身上(不知从哪里)时,我就想深入到上面的答案,然后我想我将关闭这个项目,关闭Visual Studio,然后重新打开一切。问题解决了。和错误吗?

#7


0  

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.

我在VS 2012”栏目名称”已经改变了在一个项目中,我固定它通过删除“app.config”项目,然后右键单击项目在“解决方案资源管理器”中,选择“属性”,然后“设置”,然后做出改变的一个设置,保存和重建。这就创建了一个带有正确信息的新app.config。

#8


0  

This error occurs when your project references out of date schemas. Use Visual Studio to generate new ones.

当您的项目引用过时模式时,会出现此错误。使用Visual Studio生成新的。

In Visual Studio, do the following:

在Visual Studio中,执行以下操作:

  1. Open your app.config or web.config file.
  2. 打开您的app.config或web。配置文件。
  3. Go to the XML menu and select Create Schema.
  4. 转到XML菜单并选择Create Schema。

This will trigger app#.xsd (Windows app) or web#.xsd (Website) file(s) to generate.

这将触发应用#。xsd (Windows应用程序)或web#。生成的xsd(网站)文件。

  1. Save the newly generated xsd file(s) to the root of the project.
    • Open up your App.config or web.config file, right-click in the text-editor and select properties and click the ... button next to the value for Schemas.
    • 打开您的App.config或web。配置文件,在文本编辑器中右键单击并选择properties并单击…在模式值旁边的按钮。
    • Add the newly generated xsd file(s) using the Add button.
    • 使用Add按钮添加新生成的xsd文件。
    • Click OK
    • 单击OK
  2. 将新生成的xsd文件保存到项目的根目录中。打开您的App.config或web。配置文件,在文本编辑器中右键单击并选择properties并单击…在模式值旁边的按钮。使用Add按钮添加新生成的xsd文件。单击OK

The Could not find schema information for the attribute/element error(s) should now be resolved.

不能为属性/元素错误找到模式信息,现在应该解决了。

#9


0  

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.

在我的例子中,我的代码中有一个模糊的引用。我重新启动Visual Studio并能够看到错误消息。当我解决这个问题时,另一个错误就消失了。

#10


-1  

Most of what I write has already been covered by Pressacco, but this is specific to SpecFlow.

我写的大部分内容已经被Pressacco所覆盖,但这是特定于SpecFlow的。

I was getting this message for the <specFlow> element and therefore I added a specflow.xsd file to the solution this answer (with some modifications to allow for the <plugins> element).

我为 元素获取这个消息,因此添加了一个specFlow。xsd文件到解决方案的这个答案(有一些修改允许 元素)。

Thereafter I (like Pressacco), right clicked within the file buffer of app.config and selected properties, and within Schemas, I added "specflow.xsd" to the end. The entirety of Schemas now reads:

之后,我(像Pressacco一样)在app.config和selected属性的文件缓冲区中右键单击,并在模式中添加“specflow”。xsd”结束。现在,模式的全部内容如下:

"C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\1033\DotNetConfig.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\EntityFrameworkConfig_6_1_0.xsd" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\xml\Schemas\RazorCustomSchema.xsd" "specflow.xsd"