WebConfigurationManager.OpenMachineConfiguration Yöntem

Tanım

Okuma veya yazma işlemlerine izin vermek için makine yapılandırma dosyasını bir Configuration nesne olarak açar.

Aşırı Yüklemeler

Name Description
OpenMachineConfiguration()

Okuma veya yazma işlemlerine izin vermek için geçerli bilgisayardaki makine yapılandırma dosyasını bir Configuration nesne olarak açar.

OpenMachineConfiguration(String)

Okuma veya yazma işlemlerine izin vermek için geçerli bilgisayardaki makine yapılandırma dosyasını bir Configuration nesne olarak açar.

OpenMachineConfiguration(String, String)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını, okuma veya yazma işlemlerine izin vermek için bir Configuration nesne olarak açar.

OpenMachineConfiguration(String, String, IntPtr)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını nesne Configuration olarak açar ve okuma veya yazma işlemlerine izin vermek için belirtilen güvenlik bağlamını kullanır.

OpenMachineConfiguration(String, String, String, String)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını nesne Configuration olarak açar ve okuma veya yazma işlemlerine izin vermek için belirtilen güvenlik bağlamını kullanır.

OpenMachineConfiguration()

Okuma veya yazma işlemlerine izin vermek için geçerli bilgisayardaki makine yapılandırma dosyasını bir Configuration nesne olarak açar.

public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration();
public static System.Configuration.Configuration OpenMachineConfiguration();
static member OpenMachineConfiguration : unit -> System.Configuration.Configuration
Public Shared Function OpenMachineConfiguration () As Configuration

Döndürülenler

Bir Configuration nesnesi.

Özel durumlar

Geçerli bir yapılandırma dosyası yüklenemedi.

Örnekler

Aşağıdaki örnekte, yöntemiyle yapılandırma bilgilerine erişme gösterilmektedir OpenMachineConfiguration .


// Show how to use OpenMachineConfiguration().
// It gets the machine.config file on the current
// machine and displays section information.
static void OpenMachineConfiguration1()
{
    // Get the machine.config file on the current machine.
    System.Configuration.Configuration config =
            WebConfigurationManager.OpenMachineConfiguration();

    // Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition");
    int i = 0;
    foreach (ConfigurationSection section in config.Sections)
    {
        Console.WriteLine(
            section.SectionInformation.Name + "\t" +
        section.SectionInformation.AllowExeDefinition);
        i += 1;
    }
    Console.WriteLine("[Total number of sections: {0}]", i);

    // Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath);
}
' Show how to use OpenMachineConfiguration().
' It gets the machine.config file on the current 
' machine and displays section information. 
Shared Sub OpenMachineConfiguration1()
   ' Get the machine.config file on the current machine.
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenMachineConfiguration()
   
   ' Loop to get the sections. Display basic information.
   Console.WriteLine("Name, Allow Definition")
   Dim i As Integer = 0
   Dim section As ConfigurationSection
   For Each section In  config.Sections
         Console.WriteLine((section.SectionInformation.Name + _
         ControlChars.Tab + _
         section.SectionInformation.AllowExeDefinition.ToString()))
         i += 1
     Next section
     Console.WriteLine("[Total number of sections: {0}]", i)

     ' Display machine.config path.
     Console.WriteLine("[File path: {0}]", config.FilePath)
 End Sub

Açıklamalar

yöntemi, OpenMachineConfiguration uygulamanın çalıştığı bilgisayarda makine yapılandırma dosyasını açar. Bu dosya\Microsoft.NET\Framework\version\config %windir%standart derleme dizininde bulunur.

Ayrıca bkz.

Şunlara uygulanır

OpenMachineConfiguration(String)

Okuma veya yazma işlemlerine izin vermek için geçerli bilgisayardaki makine yapılandırma dosyasını bir Configuration nesne olarak açar.

public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration(System::String ^ locationSubPath);
public static System.Configuration.Configuration OpenMachineConfiguration(string locationSubPath);
static member OpenMachineConfiguration : string -> System.Configuration.Configuration
Public Shared Function OpenMachineConfiguration (locationSubPath As String) As Configuration

Parametreler

locationSubPath
String

Makine yapılandırmasının uygulandığı uygulama yolu.

Döndürülenler

Bir Configuration nesnesi.

Özel durumlar

Geçerli bir yapılandırma dosyası yüklenemedi.

Örnekler

Aşağıdaki örnekte, yöntemiyle yapılandırma bilgilerine erişme gösterilmektedir OpenMachineConfiguration .


// Show how to use OpenMachineConfiguration(string).
// It gets the machine.config file applicable to the
// specified resource and displays section
// basic information.
static void OpenMachineConfiguration2()
{
    // Get the machine.config file applicable to the
    // specified resource.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenMachineConfiguration("configTest");

    // Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition");
    int i = 0;
    foreach (ConfigurationSection section in config.Sections)
    {
        Console.WriteLine(
            section.SectionInformation.Name + "\t" +
        section.SectionInformation.AllowExeDefinition);
        i += 1;
    }
    Console.WriteLine("[Total number of sections: {0}]", i);

    // Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath);
}
' Show how to use OpenMachineConfiguration(string).
' It gets the machine.config file applicabe to the
' specified resource and displays section 
' basic information. 
Shared Sub OpenMachineConfiguration2()
    ' Get the machine.config file applicabe to the
    ' specified reosurce.
    Dim config As System.Configuration.Configuration = _
    WebConfigurationManager.OpenMachineConfiguration( _
    "configTest")

    ' Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition")
    Dim i As Integer = 0
    Dim section As ConfigurationSection
    For Each section In config.Sections
        Console.WriteLine((section.SectionInformation.Name + _
        ControlChars.Tab + _
        section.SectionInformation.AllowExeDefinition.ToString()))
        i += 1
    Next section
    Console.WriteLine("[Total number of sections: {0}]", i)

    ' Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath)
End Sub

Açıklamalar

Bu yöntem, parametresi tarafından locationSubPath belirtilen dizin için geçerli olan makine yapılandırma dosyasını açar.

Ayrıca bkz.

Şunlara uygulanır

OpenMachineConfiguration(String, String)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını, okuma veya yazma işlemlerine izin vermek için bir Configuration nesne olarak açar.

public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration(System::String ^ locationSubPath, System::String ^ server);
public static System.Configuration.Configuration OpenMachineConfiguration(string locationSubPath, string server);
static member OpenMachineConfiguration : string * string -> System.Configuration.Configuration
Public Shared Function OpenMachineConfiguration (locationSubPath As String, server As String) As Configuration

Parametreler

locationSubPath
String

Yapılandırmanın uygulandığı uygulama yolu.

server
String

Yapılandırmasını döndürmek için sunucunun tam adı.

Döndürülenler

Bir Configuration nesnesi.

Özel durumlar

Geçerli bir yapılandırma dosyası yüklenemedi.

Örnekler

Aşağıdaki örnekte, yöntemiyle yapılandırma bilgilerine erişme gösterilmektedir OpenMachineConfiguration .


// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server and
// applicable to the specified resource and displays section
// basic information.
static void OpenMachineConfiguration3()
{
    // Get the machine.config file applicable to the
    // specified resource and on the specified server.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenMachineConfiguration("configTest",
        "myServer");

    // Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition");
    int i = 0;
    foreach (ConfigurationSection section in config.Sections)
    {
        Console.WriteLine(
            section.SectionInformation.Name + "\t" +
        section.SectionInformation.AllowExeDefinition);
        i += 1;
    }
    Console.WriteLine("[Total number of sections: {0}]", i);

    // Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath);
}
' Show how to use OpenMachineConfiguration(string, string).
' It gets the machine.config file on the specified server and
' applicabe to the specified reosurce and displays section 
' basic information. 
Shared Sub OpenMachineConfiguration3()
    ' Get the machine.config file applicabe to the
    ' specified reosurce and on the specified server.
    Dim config As System.Configuration.Configuration = _
    WebConfigurationManager.OpenMachineConfiguration( _
    "configTest", "myServer")

    ' Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition")
    Dim i As Integer = 0
    Dim section As ConfigurationSection
    For Each section In config.Sections
        Console.WriteLine((section.SectionInformation.Name + _
        ControlChars.Tab + _
        section.SectionInformation.AllowExeDefinition.ToString()))
        i += 1
    Next section
    Console.WriteLine("[Total number of sections: {0}]", i)

    ' Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath)
End Sub

Açıklamalar

Bu yöntem, parametresi tarafından belirtilen dizinde ve parametresi tarafından locationSubPath belirtilen server bilgisayarda bulunan makine yapılandırma dosyasını açar.

Ayrıca bkz.

Şunlara uygulanır

OpenMachineConfiguration(String, String, IntPtr)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını nesne Configuration olarak açar ve okuma veya yazma işlemlerine izin vermek için belirtilen güvenlik bağlamını kullanır.

public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration(System::String ^ locationSubPath, System::String ^ server, IntPtr userToken);
public static System.Configuration.Configuration OpenMachineConfiguration(string locationSubPath, string server, IntPtr userToken);
static member OpenMachineConfiguration : string * string * nativeint -> System.Configuration.Configuration
Public Shared Function OpenMachineConfiguration (locationSubPath As String, server As String, userToken As IntPtr) As Configuration

Parametreler

locationSubPath
String

Yapılandırmanın uygulandığı uygulama yolu.

server
String

Yapılandırmasını döndürmek için sunucunun tam adı.

userToken
IntPtr

nativeint

Kullanılacak hesap belirteci.

Döndürülenler

Bir Configuration nesnesi.

Özel durumlar

veya server parametreleri için userToken geçerli değerler sağlanmadı.

Geçerli bir yapılandırma dosyası yüklenemedi.

Örnekler

Aşağıdaki örnekte, yöntemiyle yapılandırma bilgilerine erişme gösterilmektedir OpenMachineConfiguration .


// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server,
// applicable to the specified resource, for the specified user
// and displays section basic information.
static void OpenMachineConfiguration4()
{
    // Get the current user token.
    IntPtr userToken =
          System.Security.Principal.WindowsIdentity.GetCurrent().Token;

    // Get the machine.config file applicable to the
    // specified resource, on the specified server for the
    // specified user.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenMachineConfiguration("configTest",
        "myServer", userToken);

    // Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition");
    int i = 0;
    foreach (ConfigurationSection section in config.Sections)
    {
        Console.WriteLine(
            section.SectionInformation.Name + "\t" +
        section.SectionInformation.AllowExeDefinition);
        i += 1;
    }
    Console.WriteLine("[Total number of sections: {0}]", i);

    // Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath);
}
' Show how to use OpenMachineConfiguration(string, string).
' It gets the machine.config file on the specified server,
' applicabe to the specified reosurce, for the specified user
' and displays section basic information. 
Shared Sub OpenMachineConfiguration4()
    ' Get the current user token.
    Dim userToken As IntPtr = _
    System.Security.Principal.WindowsIdentity.GetCurrent().Token

    ' Get the machine.config file applicabe to the
    ' specified reosurce, on the specified server for the
    ' specified user.
    Dim config As System.Configuration.Configuration = _
    WebConfigurationManager.OpenMachineConfiguration( _
    "configTest", "myServer", userToken)

    ' Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition")
    Dim i As Integer = 0
    Dim section As ConfigurationSection
    For Each section In config.Sections
        Console.WriteLine((section.SectionInformation.Name + _
        ControlChars.Tab + _
        section.SectionInformation.AllowExeDefinition.ToString()))
        i += 1
    Next section
    Console.WriteLine("[Total number of sections: {0}]", i)

    ' Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath)
End Sub

Açıklamalar

Bu yöntem, kimliğe bürünme kullanarak bir yapılandırma dosyasına erişmek için kullanılır.

Note

Hesap belirteci genellikle WindowsIdentity sınıfının bir örneğinden veya Windows API LogonUser çağrısı gibi yönetilmeyen kod çağrısı aracılığıyla alınır. Yönetilmeyen koda yapılan çağrılar hakkında daha fazla bilgi için bkz . Yönetilmeyen DLL İşlevlerini Kullanma.

Ayrıca bkz.

Şunlara uygulanır

OpenMachineConfiguration(String, String, String, String)

Belirtilen sunucudaki belirtilen makine yapılandırma dosyasını nesne Configuration olarak açar ve okuma veya yazma işlemlerine izin vermek için belirtilen güvenlik bağlamını kullanır.

public:
 static System::Configuration::Configuration ^ OpenMachineConfiguration(System::String ^ locationSubPath, System::String ^ server, System::String ^ userName, System::String ^ password);
public static System.Configuration.Configuration OpenMachineConfiguration(string locationSubPath, string server, string userName, string password);
static member OpenMachineConfiguration : string * string * string * string -> System.Configuration.Configuration
Public Shared Function OpenMachineConfiguration (locationSubPath As String, server As String, userName As String, password As String) As Configuration

Parametreler

locationSubPath
String

Yapılandırmanın uygulandığı uygulama yolu.

server
String

Yapılandırmasını döndürmek için sunucunun tam adı.

userName
String

Dosyayı açarken kullanılacak tam kullanıcı adı (Etki Alanı\Kullanıcı).

password
String

Kullanıcı adının parolası.

Döndürülenler

Bir Configuration nesnesi.

Özel durumlar

server veya userName ve password parametreleri geçersizdi.

Geçerli bir yapılandırma dosyası yüklenemedi.

Örnekler

Aşağıdaki örnekte, yöntemiyle yapılandırma bilgilerine erişme gösterilmektedir OpenMachineConfiguration .


// Show how to use OpenMachineConfiguration(string, string).
// It gets the machine.config file on the specified server,
// applicable to the specified resource, for the specified user
// and displays section basic information.
static void OpenMachineConfiguration5()
{
    // Set the user id and password.
    string user =
          System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    // Substitute with actual password.
    string password = "userPassword";

    // Get the machine.config file applicable to the
    // specified resource, on the specified server for the
    // specified user.
    System.Configuration.Configuration config =
        WebConfigurationManager.OpenMachineConfiguration("configTest",
        "myServer", user, password);

    // Loop to get the sections. Display basic information.
    Console.WriteLine("Name, Allow Definition");
    int i = 0;
    foreach (ConfigurationSection section in config.Sections)
    {
        Console.WriteLine(
            section.SectionInformation.Name + "\t" +
        section.SectionInformation.AllowExeDefinition);
        i += 1;
    }
    Console.WriteLine("[Total number of sections: {0}]", i);

    // Display machine.config path.
    Console.WriteLine("[File path: {0}]", config.FilePath);
}
 ' Show how to use OpenMachineConfiguration(string, string).
 ' It gets the machine.config file on the specified server,
 ' applicabe to the specified reosurce, for the specified user
 ' and displays section basic information. 
 Shared Sub OpenMachineConfiguration5()
     ' Set the user id and password.
     Dim user As String = _
     System.Security.Principal.WindowsIdentity.GetCurrent().Name
     ' Substitute with actual password.
     Dim password As String = "userPassword"

     ' Get the machine.config file applicabe to the
     ' specified reosurce, on the specified server for the
     ' specified user.
     Dim config As System.Configuration.Configuration = _
     WebConfigurationManager.OpenMachineConfiguration( _
     "configTest", "myServer", user, password)

     ' Loop to get the sections. Display basic information.
     Console.WriteLine("Name, Allow Definition")
     Dim i As Integer = 0
     Dim section As ConfigurationSection
     For Each section In config.Sections
         Console.WriteLine((section.SectionInformation.Name + _
         ControlChars.Tab + _
         section.SectionInformation.AllowExeDefinition.ToString()))
         i += 1
     Next section
     Console.WriteLine("[Total number of sections: {0}]", i)

     ' Display machine.config path.
     Console.WriteLine("[File path: {0}]", config.FilePath)
 End Sub

Açıklamalar

Bu yöntem, kimliğe bürünme kullanarak bir yapılandırma dosyasına erişmek için kullanılır.

Ayrıca bkz.

Şunlara uygulanır