Visual Studio always selects the wrong xsd for App.config
I interpret the problem as follows: the file DotNetConfig.xsd
has wrong (or not full) definition of the <startup>
element. Line 230 of all DotNetConfig.xsd
, DotNetConfig35.xsd
, DotNetConfig30.xsd
and DotNetConfig20.xsd
files contains
<xs:element name="startup" vs:help="configuration/startup" />
On 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 all DotNetConfigXX.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:
<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>
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 other DotNetConfigXX.xsd
files will be done based on the contents of the catalog.xml
file from the same directory, the schema of which is described here. The standard version of the catalog.xml
file contains the following lines:
<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 = ''" />
So all files having .config
extension will be interpreted by Visual Studio as files with the XSD schema described by one from above files.
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.