RuntimeEnvironment Classe

Definizione

Fornisce un insieme di metodi static che restituiscono informazioni sull'ambiente Common Language Runtime.Provides a collection of static methods that return information about the common language runtime environment.

public ref class RuntimeEnvironment
[System.Runtime.InteropServices.ComVisible(true)]
public class RuntimeEnvironment
type RuntimeEnvironment = class
Public Class RuntimeEnvironment
Ereditarietà
RuntimeEnvironment
Attributi

Esempi

Questo esempio illustra come chiamare molti dei metodi definiti dalla RuntimeEnvironment classe.This example shows how to call many of the methods defined by the RuntimeEnvironment class.

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

Costruttori

RuntimeEnvironment()

Inizializza una nuova istanza della classe RuntimeEnvironment.Initializes a new instance of the RuntimeEnvironment class.

Proprietà

SystemConfigurationFile

Ottiene il percorso del file di configurazione del sistema.Gets the path to the system configuration file.

Metodi

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Ereditato da Object)
FromGlobalAccessCache(Assembly)

Verifica se l'assembly specificato è caricato nella Global Assembly Cache.Tests whether the specified assembly is loaded in the global assembly cache.

GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Ereditato da Object)
GetRuntimeDirectory()

Restituisce la directory in cui è installato Common Language Runtime.Returns the directory where the common language runtime is installed.

GetRuntimeInterfaceAsIntPtr(Guid, Guid)

Restituisce l'interfaccia specificata nella classe specificata.Returns the specified interface on the specified class.

GetRuntimeInterfaceAsObject(Guid, Guid)

Restituisce un'istanza di un tipo che rappresenta un oggetto COM tramite un puntatore alla relativa interfaccia IUnknown.Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.

GetSystemVersion()

Ottiene il numero della versione di Common Language Runtime che esegue il processo corrente.Gets the version number of the common language runtime that is running the current process.

GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Ereditato da Object)

Si applica a