Freigeben über


RuntimeEnvironment-Klasse

Stellt eine Auflistung von static-Methoden bereit, die Informationen über die Common Language Runtime-Umgebung zurückgeben.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Class RuntimeEnvironment
'Usage
Dim instance As RuntimeEnvironment
[ComVisibleAttribute(true)] 
public class RuntimeEnvironment
[ComVisibleAttribute(true)] 
public ref class RuntimeEnvironment
/** @attribute ComVisibleAttribute(true) */ 
public class RuntimeEnvironment
ComVisibleAttribute(true) 
public class RuntimeEnvironment

Beispiel

In diesem Beispiel wird veranschaulicht, wie einige der in der RuntimeEnvironment-Klasse definierten Methoden aufgerufen werden.

using System;
using System.Reflection;
using System.Runtime.InteropServices;

public sealed class App 
{
    static void Main() 
    {       
        // Show whether the EXE assembly was loaded from the GAC or from a private subdirectory.
        Console.WriteLine("Did the {0} assembly load from the GAC? {1}",
           Assembly.GetExecutingAssembly(),
           RuntimeEnvironment.FromGlobalAccessCache(Assembly.GetExecutingAssembly()));
        
        // Show the path where the CLR was loaded from.
        Console.WriteLine("Runtime directory: {0}", RuntimeEnvironment.GetRuntimeDirectory());

        // Show the CLR's version number.
        Console.WriteLine("System version: {0}", RuntimeEnvironment.GetSystemVersion());

        // Show the path of the machine's configuration file.
        Console.WriteLine("System configuration file: {0}", RuntimeEnvironment.SystemConfigurationFile);
    }
}

// This code produces the following output.
//
// Did the RuntimeEnvironment, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// assembly load from the GAC? False
// Runtime directory: C:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\
// System version: v2.0.40607
// System configuration file: C:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\config\
// machine.config
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

int main()
{
    // Show whether the EXE assembly was loaded from the GAC or from a
    // private subdirectory.
    Console::WriteLine("Did the {0} assembly load from the GAC? {1}",
        Assembly::GetExecutingAssembly(),
        RuntimeEnvironment::FromGlobalAccessCache(
        Assembly::GetExecutingAssembly()));

    // Show the path where the CLR was loaded from.
    Console::WriteLine("Runtime directory: {0}",
        RuntimeEnvironment::GetRuntimeDirectory());

    // Show the CLR's version number.
    Console::WriteLine("System version: {0}",
        RuntimeEnvironment::GetSystemVersion());

    // Show the path of the machine's configuration file.
    Console::WriteLine("System configuration file: {0}",
        RuntimeEnvironment::SystemConfigurationFile);
}

// This code produces the following output.
//
// Did the RuntimeEnvironment, Version=0.0.0.0, Culture=neutral,
// PublicKeyToken=null
// assembly load from the GAC? False
// Runtime directory: C:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\
// System version: v2.0.40607
// System configuration file:
// C:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\config\machine.config

Vererbungshierarchie

System.Object
  System.Runtime.InteropServices.RuntimeEnvironment

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

RuntimeEnvironment-Member
System.Runtime.InteropServices-Namespace