Pergunta

The default App.config file generated by Visual Studio 2013 (with .NET Framework 4.5.1) when a WPF application is created anew, will look something like this.

<?xml version="1.0" encoding="utf-8" ?> 
<configuration>
  <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup> 
</configuration>

To this I might add a few elements that define some application settings.

<?xml version="1.0" encoding="utf-8" ?> 
<configuration>
  <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup> 
  <appSettings>
    <add key="ConfigureThisThing" value="123" />
    <add key="SwitchThatThing" value="True" />
  </appSettings>
</configuration>

Upon building, the word configuration will become underlined and there will be a warning.

The 'configuration' element is not declared.

To get rid of the warning, it seems necessary to define the <configuration> attribute xmlns.

Is there a default attribute value available somewhere that is very un-constraining and serves simply to get rid of the warning?

There is this particular stackoverflow answer that suggests

xmlns="schema URL"

and while that does get rid of the warning, it does not appear to be a properly formed URL, so it does not seem to make sense. If such an attribute value can be supported or explained or justified, then I will gladly accept it, however there appears to be no information at this MSDN configuration element description that would justify such an attribute value.

This MSDN document says that the attribute should specify a URL.

Foi útil?

Solução

It appears that the xmlns attribute does not have to be machine interpreted since it is not required to be used for retrieval. From wikipedia right... now ... is this description.

A namespace name is a uniform resource identifier (URI). Typically, the URI chosen for the namespace of a given XML vocabulary describes a resource under the control of the author or organization defining the vocabulary, such as a URL for the author's Web server. However, the namespace specification does not require nor suggest that the namespace URI be used to retrieve information; it is simply treated by an XML parser as a string.

Given that, it is easy to provide a non-constraining but accurate URI, such as a URL that is under the control of the person specifying it even if the control serves only to guarantee uniqueness and falls short of offering any automated functionality.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top