RuntimeEnvironment Klasse

Definition

Stellt eine Auflistung von static Methoden bereit, die Informationen zur Laufzeitumgebung der allgemeinen Sprache zurückgeben.

public ref class RuntimeEnvironment
public ref class RuntimeEnvironment abstract sealed
public class RuntimeEnvironment
[System.Runtime.InteropServices.ComVisible(true)]
public class RuntimeEnvironment
public static class RuntimeEnvironment
type RuntimeEnvironment = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type RuntimeEnvironment = class
Public Class RuntimeEnvironment
Vererbung
RuntimeEnvironment
Attribute

Beispiele

In diesem Beispiel wird gezeigt, wie viele der von der RuntimeEnvironment Klasse definierten Methoden aufgerufen werden.

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
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.
        Assembly assem = typeof(App).Assembly;
        Console.WriteLine("Did the {0} assembly load from the GAC? {1}",
           assem, RuntimeEnvironment.FromGlobalAccessCache(assem));

        // 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
Imports System.Reflection
Imports System.Runtime.InteropServices

Public NotInheritable Class App
    Shared Sub Main()
        ' Show whether the EXE assembly was loaded from the GAC or from a private subdirectory.
        Dim assem As Assembly = GetType(App).Assembly
        Console.WriteLine("Did the {0} assembly load from the GAC? {1}", 
                          assem, RuntimeEnvironment.FromGlobalAccessCache(assem))
        ' 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)
    End Sub
End Class

' 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

Konstruktoren

Name Beschreibung
RuntimeEnvironment()
Veraltet.

Initialisiert eine neue Instanz der RuntimeEnvironment-Klasse.

Eigenschaften

Name Beschreibung
SystemConfigurationFile

Ruft den Pfad zur Systemkonfigurationsdatei ab.

Methoden

Name Beschreibung
FromGlobalAccessCache(Assembly)

Überprüft, ob die angegebene Assembly im globalen Assemblycache geladen wird.

GetRuntimeDirectory()

Gibt das Verzeichnis zurück, in dem die Common Language Runtime installiert ist.

GetRuntimeInterfaceAsIntPtr(Guid, Guid)

Gibt die angegebene Schnittstelle für die angegebene Klasse zurück.

GetRuntimeInterfaceAsObject(Guid, Guid)

Gibt eine Instanz eines Typs zurück, die ein COM-Objekt durch einen Zeiger auf die IUnknown Schnittstelle darstellt.

GetSystemVersion()

Ruft die Versionsnummer der Common Language Runtime ab, die den aktuellen Prozess ausführt.

Gilt für: