RuntimeEnvironment Class
Collapse the table of content
Expand the table of content

RuntimeEnvironment Class


Provides a collection of static methods that return information about the common language runtime environment.

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


public class RuntimeEnvironment


Obsolete.Initializes a new instance of the RuntimeEnvironment class.


Gets the path to the system configuration file.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Tests whether the specified assembly is loaded in the global assembly cache.


Serves as the default hash function. (Inherited from Object.)


Returns the directory where the common language runtime is installed.

System_CAPS_pubmethodSystem_CAPS_staticGetRuntimeInterfaceAsIntPtr(Guid, Guid)

Returns the specified interface on the specified class.

System_CAPS_pubmethodSystem_CAPS_staticGetRuntimeInterfaceAsObject(Guid, Guid)

Returns an instance of a type that represents a COM object by a pointer to its IUnknown interface.


Gets the version number of the common language runtime that is running the current process.


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

This example shows how to call many of the methods defined by the RuntimeEnvironment class.

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=, 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

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft