.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:


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -