ConfigurationSection 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ConfigurationSection 클래스의 새 인스턴스를 초기화합니다.
protected:
ConfigurationSection();
protected ConfigurationSection ();
Protected Sub New ()
예제
다음 예제에서는 사용 하는 방법을 보여 있습니다는 ConfigurationSection 생성자입니다. 이 예제에서는 라는 CustomSection
사용자 지정 섹션 클래스를 만들었다고 가정합니다. 이러한 클래스의 예제는 클래스 개요를 ConfigurationSection 참조하세요.
// Create a custom section.
static void CreateSection()
{
try
{
CustomSection customSection;
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Create the section entry
// in the <configSections> and the
// related target section in <configuration>.
if (config.Sections["CustomSection"] == null)
{
customSection = new CustomSection();
config.Sections.Add("CustomSection", customSection);
customSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
catch (ConfigurationErrorsException err)
{
Console.WriteLine(err.ToString());
}
}
' Create a custom section.
Shared Sub CreateSection()
Try
Dim customSection As CustomSection
' Get the current configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Create the section entry
' in the <configSections> and the
' related target section in <configuration>.
If config.Sections("CustomSection") Is Nothing Then
customSection = New CustomSection()
config.Sections.Add("CustomSection", customSection)
customSection.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
End If
Catch err As ConfigurationErrorsException
Console.WriteLine(err.ToString())
End Try
End Sub
설명
생성자를 사용 ConfigurationSection 하려면 먼저 사용자 지정 섹션 형식을 정의해야 합니다. 예제는 클래스 개요를 ConfigurationSection 참조하세요.