RuntimeEnvironment 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供一个返回有关公共语言运行时环境的信息的 static
方法。
public ref class RuntimeEnvironment abstract sealed
public ref class RuntimeEnvironment
public static class RuntimeEnvironment
public class RuntimeEnvironment
[System.Runtime.InteropServices.ComVisible(true)]
public class RuntimeEnvironment
type RuntimeEnvironment = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type RuntimeEnvironment = class
Public Class RuntimeEnvironment
- 继承
-
RuntimeEnvironment
- 属性
示例
此示例演示如何调用 类定义的 RuntimeEnvironment 许多方法。
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
构造函数
RuntimeEnvironment() |
已过时.
初始化 RuntimeEnvironment 类的新实例。 |
属性
SystemConfigurationFile |
已过时.
获取系统配置文件的路径。 |
方法
FromGlobalAccessCache(Assembly) |
测试是否将指定的程序集加载到全局程序集缓存中。 |
GetRuntimeDirectory() |
返回公共语言运行时的安装目录。 |
GetRuntimeInterfaceAsIntPtr(Guid, Guid) |
已过时.
返回指定类上的指定接口。 |
GetRuntimeInterfaceAsObject(Guid, Guid) |
已过时.
返回通过指向其 |
GetSystemVersion() |
获取运行当前进程的公共语言运行时的版本号。 |