<configSections> 的 <remove> 項目
移除預先定義的區段或區段群組。
<configuration>
<configSections>
<remove>
<remove name="section name or section group name" />
必要屬性
屬性 | 說明 |
---|---|
name | 指定要移除的區段或區段群組的名稱。 |
備註
您可以使用 <remove> 項目來從您的應用程式中移除已在組態檔階層架構較高層級中定義的區段或區段群組。
範例
下列範例顯示如何在應用程式組態檔中使用 <remove> 項目,以移除先前定義在電腦組態檔中的區段。
下列電腦組態檔程式碼宣告區段 <sampleSection>
。
<!-- Machine.config file. -->
<configuration>
<configSections>
<section name="sampleSection"
type="System.Configuration.SingleTagSectionHandler" />
</configSections>
<sampleSection setting1="Value1" setting2="value two"
setting3="third value" />
</configuration>
下列應用程式組態檔程式碼會將 <sampleSection>
區段移除。在移除之後,應用程式無法擷取 <sampleSection>
中的設定。
<!-- Application configuration file. -->
<configuration>
<configSections>
<remove name="sampleSection"/>
</configSections>
</configuration>
組態檔
這個項目可以在不是位於應用程式目錄層級的應用程式組態檔、電腦組態檔 (Machine.config) 和 Web.config 檔案中使用。