等效于核心clr的Environment.Version

编程入门 行业动态 更新时间:2024-10-22 08:00:17
本文介绍了等效于核心clr的Environment.Version的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下代码对dnx451框架有效,但对dnxcore50

The following code is valid for the dnx451 framework but not the dnxcore50

string ver = Environment.Version

此方法不存在:

dnxcore50框架中是否有等效的属性?

Is there an equivalent property in the dnxcore50 framework?

根据Victors的答案,您可以使用PlatformServices.Default.Runtime,例如:

as per Victors answer you can use PlatformServices.Default.Runtime eg:

Console.WriteLine("env: {0} {1}", PlatformServices.Default.Runtime.RuntimeType, PlatformServices.Default.Runtime.RuntimeVersion);

输出:(在dnx451上)

output: (on dnx451)

env:Clr 1.0.0-rc1-16231

env: Clr 1.0.0-rc1-16231

输出:(在dnxcore50上)

output: (on dnxcore50)

env:CoreClr 1.0.0-rc1-16231

env: CoreClr 1.0.0-rc1-16231

推荐答案

您可以使用 IRuntimeEnvironment 以获得有关运行时的信息.可以使用以下属性:

You can use the properties in IRuntimeEnvironment to get information about the runtime. The following properties are available:

  • RuntimeType
  • RuntimeArchitecture
  • RuntimeVersion
  • RuntimePath

更多推荐

等效于核心clr的Environment.Version

本文发布于:2023-11-17 07:03:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609237.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:核心   clr   Version   Environment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!