RuntimeEnvironment-Klasse
Veröffentlicht: Oktober 2016
Stellt eine Auflistung von static Methoden, die Informationen über die common Language Runtime-Umgebung zurückgeben.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Vererbungshierarchie
System.Object
System.Runtime.InteropServices.RuntimeEnvironment
Syntax
[ComVisibleAttribute(true)]
public class RuntimeEnvironment
[ComVisibleAttribute(true)]
public ref class RuntimeEnvironment
[<ComVisibleAttribute(true)>]
type RuntimeEnvironment = class end
<ComVisibleAttribute(True)>
Public Class RuntimeEnvironment
Konstruktoren
Name | Beschreibung | |
---|---|---|
RuntimeEnvironment() | Veraltet. Initialisiert eine neue Instanz der RuntimeEnvironment-Klasse. |
Eigenschaften
Name | Beschreibung | |
---|---|---|
SystemConfigurationFile | Ruft den Pfad der Konfigurationsdatei System. |
Methoden
Name | Beschreibung | |
---|---|---|
Equals(Object) | Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.(Geerbt von „Object“.) |
|
Finalize() | Gibt einem Objekt Gelegenheit zu dem Versuch, Ressourcen freizugeben und andere Bereinigungen durchzuführen, bevor es von der Garbage Collection freigegeben wird.(Geerbt von „Object“.) |
|
FromGlobalAccessCache(Assembly) | Testet, ob die angegebene Assembly im globalen Assemblycache geladen wird. |
|
GetHashCode() | Fungiert als die Standardhashfunktion.(Geerbt von „Object“.) |
|
GetRuntimeDirectory() | Gibt das Verzeichnis, 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, der durch einen Zeiger auf ein COM-Objekt stellt die IUnknown Schnittstelle. |
|
GetSystemVersion() | Ruft die Versionsnummer der common Language Runtime, die der aktuelle Prozess ausgeführt wird. |
|
GetType() | Ruft den Type der aktuellen Instanz ab.(Geerbt von „Object“.) |
|
MemberwiseClone() | Erstellt eine flache Kopie des aktuellen Object.(Geerbt von „Object“.) |
|
ToString() | Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.(Geerbt von „Object“.) |
Beispiele
In diesem Beispiel wird veranschaulicht, wie viele der definierten Methoden aufrufen, die RuntimeEnvironment Klasse.
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
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
Versionsinformationen
.NET Framework
Verfügbar seit 1.1
Threadsicherheit
Alle öffentlichen statischen Member ( Shared in Visual Basic) dieses Typs sind threadsicher. Die Threadsicherheit für Instanzmember ist nicht garantiert.
Siehe auch
System.Runtime.InteropServices-Namespace
Zurück zum Anfang