以下代码适用于dnx451
框架,但不适用于dnxcore50
string ver = Environment.Version
此方法不存在:
dnxcore50 框架中是否有等效的属性?
更新
根据 Victors 的回答,您可以使用 PlatformServices.Default.Runtime
例如:
Console.WriteLine("env: {0} {1}", PlatformServices.Default.Runtime.RuntimeType, PlatformServices.Default.Runtime.RuntimeVersion);
输出:(在 dnx451 上)
env: Clr 1.0.0-rc1-16231
输出:(在 dnxcore50 上)
env: CoreClr 1.0.0-rc1-16231
最佳答案
您可以使用 IRuntimeEnvironment 中的属性获取有关运行时的信息。以下属性可用:
- 运行时类型
- 运行时架构
- 运行时版本
- 运行时路径
关于c# - 核心 clr 中的 Environment.Version 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35145661/