次の方法で共有


configSections の clear 要素 (全般設定スキーマ)

更新 : 2007 年 11 月

継承したセクションとセクション グループへのすべての参照を削除し、現在の section 要素と sectionGroup 要素によって追加されたセクションとセクション グループだけを有効にします。

configuration 要素 (全般設定スキーマ)
  configSections 要素 (全般設定スキーマ)
    configSections の clear 要素 (全般設定スキーマ)
      configuration 要素 (全般設定スキーマ)
        configSections 要素 (全般設定スキーマ)
          configSections の sectionGroup 要素 (全般設定スキーマ)
            configSections の clear 要素 (全般設定スキーマ)

<clear />

属性と要素

以降のセクションでは、属性、子要素、および親要素について説明します。

属性

なし。

子要素

なし。

親要素

要素

説明

configuration

共通言語ランタイムおよび .NET Framework ベースのアプリケーションで使用されるすべての構成ファイルで必要なルート要素です。

configSections

構成セクションと名前空間の宣言を指定します。

sectionGroup

構成セクション ハンドラと構成セクションの間の関連付けを定義します。

解説

clear 要素は、継承したセクションとセクション グループへのすべての参照を削除し、現在の section 要素と sectionGroup 要素によって追加されたセクションとセクション グループだけを有効にします。

ハンドラの参照が削除された後に、構成ファイルが構成セクションを使用しようとすると、ASP.NET により "認識できない構成セクション element_name" というサーバー エラーが発行されます。

使用例

アプリケーション構成ファイルで clear 要素を使用して、Machine.config ファイルで定義済みのセクションを削除するコード例を次に示します。

Machine.config ファイルの次のコードでは、アプリケーション構成ファイルの前に読み取られる sampleSection と anotherSampleSection の 2 つのセクションが宣言されます。

<configuration>
   <configSections>
      <section name="sampleSection"
               type="System.Configuration.SingleTagSectionHandler" />
      <section name="anotherSampleSection"
               type="System.Configuration.NameValueSectionHandler" />
   </configSections>
   <sampleSection setting1="Value1" setting2="value two" 
                  setting3="third value" />
</configuration>

すべての宣言済みセクションを消去するアプリケーション構成ファイルのコードは、次のとおりです。アプリケーションは、Machine.config ファイルで宣言されたセクションのどちらでも設定を使用または取得できません。ただし、anotherSection は clear 要素の後にあるため、アプリケーションは anotherSection の設定は使用できます。

<configuration>

<configSections>

<clear/>

<section name="anotherSection"

type="System.Configuration.NameValueSectionHandler" />

</configSections>

</configuration>

要素情報

構成セクション ハンドラ

該当なし。

構成メンバ

Clear()

Clear()

構成できる場所

Machine.config

ルート レベルの Web.config

アプリケーション レベルの Web.config

仮想ディレクトリ レベルまたは物理ディレクトリ レベルの Web.config

必要条件

Microsoft Internet Information Services (IIS) バージョン 5.0、5.1、または 6.0

.NET Framework Version 1.0、1.1、または 2.0

Microsoft Visual Studio 2003 または Visual Studio 2005

参照

概念

ASP.NET 構成ファイルの階層と継承

ASP.NET 構成ファイルの編集

ASP.NET の構成のシナリオ

参照

configSections 要素 (全般設定スキーマ)

configSections の sectionGroup 要素 (全般設定スキーマ)

configSections の section 要素 (全般設定スキーマ)

configSections の remove 要素 (全般設定スキーマ)

configuration 要素 (全般設定スキーマ)

その他の技術情報

全般構成設定 (ASP.NET)

ASP.NET 構成設定

ASP.NET 構成ファイル

ASP.NET Web サイトの管理

ASP.NET 構成 API