Nowadays, .NET applications can be created, among others, with .NET Core and with the full .NET framework.
Both .NET Core and the full .NET Framework uses assembly files (dll files) to package the application.
Now given an assembly file loaded in a C# program via Reflection, how to know which environment(.NET Core, Full Framework...) it is targeting?
UPDATE
This turned out to be a duplicate question, I wanted to highlight the most helpful answer in the pre-existing question:
Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath("Lib.dll");
var targetFrwrk = assembly.GetCustomAttribute<TargetFrameworkAttribute>().FrameworkName;
The TargetFrameworkAttribute.FrameworkName
property contains the name of the target framework. For example: .NETStandard,Version=v1.6
or .NETFramework,Version=v4.5.2
.