Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 305
Kingpin Avatar asked Feb 08 '18 08:02

Kingpin


People also ask

Where is .NET Framework DLL?

dll files in the %systemroot%\Microsoft.NET\Framework folder and the %systemroot%\Microsoft.NET\Framework64 folder if the folder exists. Click on each of the files, view properties, and click version tab to determine the version installed.

How do I find .NET standard version?

NET in the File System. You can check your installed versions of . NET by navigating to Microsoft.NET\Framework under your Windows folders. The complete path is usually 'C:\Windows\Microsoft.NET\Framework.

What is .NET standard Framework?

NET Standard is a formal specification of . NET APIs that are available on multiple . NET implementations. The motivation behind . NET Standard was to establish greater uniformity in the .

What is DLL in .NET framework?

DLL (Dynamic Link Library) In . NET Framework when we compile a Console Application or a Windows Application, it generates EXE, whereas when we compile a Class Library Project or ASP.NET web application, then it generates DLL. In.NET framework, both EXE and DLL are called assemblies.


1 Answers

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

like image 96
NightOwl888 Avatar answered Oct 07 '22 01:10

NightOwl888