LoginSignup
1
4

More than 5 years have passed since last update.

App.config で「'configuration' 要素が宣言されていません」の警告が出る場合

Posted at

'configuration' 要素が宣言されていません

プロジェクトの「対象のフレームワーク」が catalog.xml で判定できない場合、
スキーマが読み込まれず、XMLの検証(validation)が出来ないため警告となるようです。

catalog.xml は「管理者として実行」したエディタで修正する必要があるので、
対象としたフレームワークの Developer Pack や Targeting Pack のインストールに失敗していると考えた方が良さそうです。

手作業での修正

「対象のフレームワーク」が ".NET Framework 4.6.1" の場合に警告が表示される際の修正例。
警告は消えますが、他に影響があるかもしれません。
修正は自己責任で。

パスの確認

catalog.xml のフォルダは、Visual Studio の設定で変更可能なので、次の手順で設定を確認します。

Visual Studio 2013の場合

  1. [ツール] メニューの [オプション]
  2. [テキスト エディター] - [XML] - [その他]
  3. [スキーマ]項目

次のような設定になっていると思います。

"%VsInstallDir%¥xml¥Schemas"

catalog.xml の修正

テキストエディタを「管理者として実行」で起動。
前段で確認したパスの catalog.xml を開く。

Associationタグの condition属性を修正します。

修正前
<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or $TargetFrameworkMoniker = ''" />
修正後
<Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.6.') or $TargetFrameworkMoniker = ''" />

こんな感じになれば良いかと。

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/dotNetConfig40.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.0')" />
  <Association extension="config" schema="%InstallRoot%/xml/schemas/dotNetConfig45.xsd" condition="$TargetFrameworkMoniker = '.NETFramework,Version=v4.5'" />
  <Association extension="config" schema="%InstallRoot%/xml/schemas/%LCID%/dotNetConfig.xsd" condition="starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.5.') or starts-with($TargetFrameworkMoniker, '.NETFramework,Version=v4.6') or $TargetFrameworkMoniker = ''" />
</SchemaCatalog>

参考

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4