.net 4.0 - How to get info about the current runtime in C#? -
in c# program, need information runtime environment in program running.
essentially, need know if current program running in .net core or in full .net framework 4.x.
something following might work:
public string getruntimeversion() { #if net451 return "net451"; #elseif netcoreapp11 return "netcoreapp11"; #elseif netstandard14 return "netcoreapp14"; #endif ... }
but there better way?
microsoft.extensions.platformabstractions !
using microsoft.extensions.platformabstractions; var runtimeinfo = platformservices.default.application.runtimeframework;
the platformservices.default.application.runtimeframework
property contains info such identifier of runtime , version. , available on .net core.
credit goes to:
jurjen pointing out
system.environment.version
somehow led me victor hurdugaci's comment
Comments
Post a Comment