Search code examples
c#.net-core.net-standard.net-framework-version

Determine the framework in a .NET Standard DLL at runtime


In a .NET Standard project is there a way to determine if the DLL is run in .NET Core or the regular .NET Framework at runtime?

I want to handle things differently for different .NET platforms.


Solution

  • Use the RuntimeInformation.FrameworkDescription Property from the System.Runtime.InteropServices namespace.

    Returns a string that indicates the name of the .NET installation on which an app is running.

    The property returns one of the following strings:

    • ".NET Core".

    • ".NET Framework".

    • ".NET Native".