共用方式為


SectionInformation.AllowDefinition 屬性

定義

取得或設定值,指出可以在組態檔階層架構中的哪一個位置定義關聯的組態區段。

public:
 property System::Configuration::ConfigurationAllowDefinition AllowDefinition { System::Configuration::ConfigurationAllowDefinition get(); void set(System::Configuration::ConfigurationAllowDefinition value); };
public System.Configuration.ConfigurationAllowDefinition AllowDefinition { get; set; }
member this.AllowDefinition : System.Configuration.ConfigurationAllowDefinition with get, set
Public Property AllowDefinition As ConfigurationAllowDefinition

屬性值

值,指出可以在組態檔階層架構中的哪一個位置宣告關聯的 ConfigurationSection 物件。

例外狀況

選取的值與已定義的值發生衝突。

範例

本節中的範例示範如何在存取組態檔中相關的區段信息之後取得 AllowDefinition 屬性值。

下列範例會取得 SectionInformation 物件。

// Get the current configuration file.
System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

// Get the section.
UrlsSection section =
    (UrlsSection)config.GetSection("MyUrls");

SectionInformation sInfo =
    section.SectionInformation;
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)

' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)

Dim sInfo As SectionInformation = _
section.SectionInformation

下列範例會取得 AllowDefinition 值。

ConfigurationAllowDefinition allowDefinition =
    sInfo.AllowDefinition;
Console.WriteLine("Allow definition: {0}", 
    allowDefinition.ToString() );
Dim allowDefinition _
As ConfigurationAllowDefinition = _
sInfo.AllowDefinition
Console.WriteLine("Allow definition: {0}", _
allowDefinition.ToString())

備註

AllowDefinition 僅適用於 Web 應用程式的組態檔。 針對用戶端應用程式,您必須使用 AllowExeDefinition

適用於

另請參閱