Visual Studio 总是为 App.config 选择错误的 xsd
首先,我有一个具有此配置的 .NET 4.0 应用程序:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
我遇到了与此问题相同的问题: app.config 转换为 Visual Studio 2010 / .Net 4.0 后“找不到架构信息”:无法识别supportedRuntime元素由编辑器编辑,产生提示。
然后我按照答案进行操作:我在 app.config 编辑器中并转到“属性”窗口。我在那里选择了模式条目。
我删除了 DotNetConfig.xsd 的选择并选择了 DotNetConfig35.xsd,但 VS 总是自动再次添加 DotNetConfig.xsd。即使我明确地将其设置为“不使用此架构”,甚至从列表中删除该架构 - 它也会自动再次添加到列表中并被选中。
因为我现在选择了两个定义相同元素的模式,所以我收到了很多警告。
如何更改架构以使用 DotNetConfig35.xsd 并且不再次自动添加 DotNetConfig.xsd?
first of all, I have a .NET 4.0 application with this configuration:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
I had the same problem like the one in this question: app.config "Could not find schema information" after converting to Visual Studio 2010 / .Net 4.0 : The supportedRuntime element was not recognized by the editor, resulting in a hint.
I then followed the answer: I was in the app.config editor and went to the Properties window. There I selected the Schemas entry.
I removed the selection of the DotNetConfig.xsd and selected the DotNetConfig35.xsd instead, but VS always automatically adds the DotNetConfig.xsd again. Even if I set it explicitely to "do not use this schema" or even remove the schema from the list - it is automatically added to the list again and selected.
Because I now have two schemas selected that define the same elements I get a lot of warnings.
How can I change the schema to use the DotNetConfig35.xsd and NOT have the DotNetConfig.xsd automatically added again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对该问题的解释如下:文件
DotNetConfig.xsd
的
元素定义错误(或不完整)。所有DotNetConfig.xsd
、DotNetConfig35.xsd
、DotNetConfig30.xsd
和DotNetConfig20.xsd
文件的第 230 行包含On另一方面,微软将启动设置架构描述为非空元素。因此,我建议替换
DotNetConfig.xsd
和%ProgramFiles%\Microsoft Visual Studio 10.0\Xml\Schemas 中的所有
目录(或 64 位系统上的DotNetConfigXX.xsd
文件中的上述行%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Xml\Schemas
目录),其中包含以下行:进行此类修改并重新启动 Visual Studio 2010 后您将不会收到您所描述的警告。当然,我们可以以更详细的方式定义所有属性或元素的模式(特别是如果我们找到
部分的更详细文档),但我想描述一下原因只有问题和解决它的一种方法。顺便说一下,
DotNetConfig.xsd
、DotNetConfig35.xsd
和其他DotNetConfigXX.xsd
文件之间的选择将根据DotNetConfigXX.xsd
文件的内容来完成。同一目录中的 code>catalog.xml 文件,其架构描述为 这里。catalog.xml
文件的标准版本包含以下几行:因此,所有具有
.config
扩展名的文件都将被 Visual Studio 解释为具有由一个描述的 XSD 架构的文件从上面的文件。I interpret the problem as follows: the file
DotNetConfig.xsd
has wrong (or not full) definition of the<startup>
element. Line 230 of allDotNetConfig.xsd
,DotNetConfig35.xsd
,DotNetConfig30.xsd
andDotNetConfig20.xsd
files containsOn the other side Microsoft describes the startup settings schema as a non-empty element. So I suggest to replace the above line in
DotNetConfig.xsd
and in allDotNetConfigXX.xsd
files from the%ProgramFiles%\Microsoft Visual Studio 10.0\Xml\Schemas
directory (or%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Xml\Schemas
directory on 64-bit systems) with the following lines:After such modification and restarting of Visual Studio 2010 you will not have the warnings which you described. Of course one can define the schema of all attributes or elements in a more detailed manner (especially if we find more detailed documentation of the
<startup>
section), but I want to describe the reason of the problem only and one way to fix it.By the way the choice between
DotNetConfig.xsd
,DotNetConfig35.xsd
and otherDotNetConfigXX.xsd
files will be done based on the contents of thecatalog.xml
file from the same directory, the schema of which is described here. The standard version of thecatalog.xml
file contains the following lines:So all files having
.config
extension will be interpreted by Visual Studio as files with the XSD schema described by one from above files.当我遇到这个问题时,未取消检查架构的原因是打开了多个 Visual Studio 实例。
(我用一个项目打开 VS2015,同时用另一个项目打开 VS2013。)
注意,多个版本的 Visual Studio 以及在同一个项目/解决方案上来回切换似乎也是重复架构的一些问题的原因首先发生的。
When I ran into this problem, the reason un-checking the schema didn't take turned out to be having multiple instances of Visual Studio open.
(I had VS2015 open with one project and VS2013 also open at the same time with a different project.)
Note, multiple versions of Visual Studio and switching back and forth on the same project/solution also seems to be how some issues with repeated schemas occurred in the first place.
这是一篇旧帖子 - 但我刚刚遇到了同样的问题。
我采用的方法与 Ken Johnsrude 上面建议的方法相同 - 创建一个新的 .xsd 文件:
http://w3stack.org/question/c-how-to-fix-error-could-not-find -通过创建架构来获取属性元素的架构信息/
MSVS >打开项目app.config
XML>创建架构
这将在 %TEMP% 中创建“app.xsd”
将 app.xsd 移至项目目录
App.Config,右键单击 >属性>模式> ...
应用程序.xsd >使用>使用此架构 = YES
This is an old post - but I just encountered the same problem.
The approach I took was the same one Ken Johnsrude suggested above - to create a new .xsd file:
http://w3stack.org/question/c-how-to-fix-error-could-not-find-schema-information-for-the-attributeelement-by-creating-schema/
MSVS > Open project app.config
XML > Create Schema
This will create "app.xsd" in %TEMP%
Move app.xsd to project directory
App.Config, Right-click > Properties > Schemas > ...
app.xsd > Use > Use this schema = YES