以下代码对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
发布评论