问题
Looking at the following JetBrains dotPeek view of some given assemblies, how can I programmatically determine the platform such assemblies have been compiled against?
I have tried the following method which does not work for assemblies compiled in .NET Core.
public static string GetFrameworkVersion(Assembly assembly)
{
var targetFrameAttribute = assembly.GetCustomAttributes(true)
.OfType<TargetFrameworkAttribute>().FirstOrDefault();
if (targetFrameAttribute == null)
{
return ".NET 2, 3 or 3.5";
}
return targetFrameAttribute.FrameworkDisplayName.Replace(".NET Framework", ".NET");
}
How is dotPeek able to obtain such details?
来源:https://stackoverflow.com/questions/46897911/how-can-i-find-the-platform-a-net-assembly-has-been-compiled-against-programmat