ConfigurationManager.OpenMachineConfiguration メソッド
アセンブリ: System.Configuration (system.configuration.dll 内)

Public Shared Function OpenMachineConfiguration As Configuration
Dim returnValue As Configuration returnValue = ConfigurationManager.OpenMachineConfiguration
public static Configuration OpenMachineConfiguration ()
public: static Configuration^ OpenMachineConfiguration ()
public static Configuration OpenMachineConfiguration ()
Configuration オブジェクト。


マシン構成設定は、ローカル アプリケーション用にオーバーライドされている場合を除き、コンピュータ全体とそのコンピュータに存在するすべてのアプリケーションに適用されます。マシン構成設定は、.NET Framework の現在実行中のバージョンの Machine.config ファイルから読み取られます。Machine.config ファイルは、次のサブディレクトリにあります。
%windir%\Microsoft.NET\Framework\version\config
![]() |
---|
リソースの Configuration オブジェクトを取得するには、設定の継承元となるすべての構成ファイルに対する読み取り特権がコードに付与されている必要があります。構成ファイルを更新するには、構成ファイルとそれを格納するディレクトリの両方に対する書き込み特権も、コードに付与されている必要があります。コンピュータにインストールされている可能性のある .NET Framework の他のバージョンの Machine.config ファイルにはアクセスできません。 |

OpenMachineConfiguration メソッドを使用して、構成ファイルに含まれるすべてのセクションを取得する方法を次のコード例に示します。
' Get all the sections in machine.config. ' Show how to use the OpenMachineConfiguration method. Shared Sub GetMachineSections() ' Get the machine.config file. Dim config As System.Configuration.Configuration = _ ConfigurationManager.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.ToString() + _ ControlChars.Tab + _ section.SectionInformation.AllowExeDefinition.ToString())) i += 1 Next section Console.WriteLine("[Total number of sections: {0}]", i.ToString()) ' Display machine.config path. Console.WriteLine("[File path: {0}]", config.FilePath) End Sub 'GetMachineSections
// Get all the sections in machine.config. // Show how to use the OpenMachineConfiguration method. static void GetMachineSections() { // Get the machine.config file. System.Configuration.Configuration config = ConfigurationManager.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); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からConfigurationManager.OpenMachineConfiguration メソッドを検索する場合は、下記のリンクをクリックしてください。

- ConfigurationManager.OpenMachineConfiguration メソッドのページへのリンク