Seb*_*ter 22 xsd app-config visual-studio-2010
首先,我有一个具有此配置的.NET 4.0应用程序:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我遇到了与此问题中的问题相同的问题:转换为Visual Studio 2010/.Net 4.0后,app.config"无法找到架构信息":编辑器无法识别supportedRuntime元素,从而产生提示.
然后,我接着回答:我在app.config编辑器中,然后转到"属性"窗口.在那里我选择了Schemas条目.
我删除了DotNetConfig.xsd的选择并改为选择了DotNetConfig35.xsd,但VS总是会再次自动添加DotNetConfig.xsd.即使我明确地将其设置为"不使用此架构",甚至从列表中删除架构 - 它也会自动再次添加到列表中并进行选择.
因为我现在选择了两个定义相同元素的模式,所以我得到了很多警告.
如何更改架构以使用DotNetConfig35.xsd并且不再自动添加DotNetConfig.xsd?
Ole*_*leg 41
我将问题解释如下:文件DotNetConfig.xsd的<startup>元素定义错误(或不完整).该行所有的230 DotNetConfig.xsd,DotNetConfig35.xsd,DotNetConfig30.xsd和DotNetConfig20.xsd文件包含
<xs:element name="startup" vs:help="configuration/startup" />
Run Code Online (Sandbox Code Playgroud)
另一方面,Microsoft将启动设置架构描述为不是空元素.因此,我建议将目录(或64位系统上的目录)DotNetConfig.xsd中的所有DotNetConfigXX.xsd文件中的上述行替换为以下行%ProgramFiles%\Microsoft Visual Studio 10.0\Xml\Schemas%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Xml\Schemas
<xs:element name="startup" vs:help="configuration/startup">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="requiredRuntime" vs:help="configuration/startup/requiredRuntime">
<xs:complexType>
<xs:attribute name="version" type="xs:string" use="optional" />
<xs:attribute name="safemode" type="xs:boolean" use="optional" />
</xs:complexType>
</xs:element>
<xs:element name="supportedRuntime" minOccurs="1" maxOccurs="unbounded" vs:help="configuration/startup/supportedRuntime">
<xs:complexType>
<xs:attribute name="version" type="xs:string" use="optional" />
<xs:attribute name="sku" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="useLegacyV2RuntimeActivationPolicy" type="xs:boolean" use="optional" />
<!-- see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx -->
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
在修改并重新启动Visual Studio 2010之后,您将不会收到所描述的警告.因为可以更详细地定义所有属性或元素的模式(特别是如果我们找到该<startup>部分的更详细的文档),但我想仅描述问题的原因和解决它的一种方法.
通过之间的选择的方式DotNetConfig.xsd,DotNetConfig35.xsd其他的和DotNetConfigXX.xsd文件将根据包含来完成catalog.xml从同一目录,其中叙述模式文件在这里.该catalog.xml文件的标准版本包含以下行
<Association extension="config" schema="%InstallRoot%/xml/schemas/dotNetConfig20.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v2.')" />
<Association extension="config" schema="%InstallRoot%/xml/schemas/dotNetConfig30.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v3.0')" />
<Association extension="config" schema="%InstallRoot%/xml/schemas/dotNetConfig35.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v3.5')" />
<Association extension="config" schema="%InstallRoot%/xml/schemas/dotNetConfig.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.') or $TargetFrameworkMoniker = ''" />
Run Code Online (Sandbox Code Playgroud)
因此,所有具有.config扩展名的文件都将由Visual Studio解释为具有上述文件中描述的XSD架构的文件.
| 归档时间: |
|
| 查看次数: |
16074 次 |
| 最近记录: |