如何正确找到构建程序集所针对的 .NET 运行时?

How can I correctly find the .NET runtime against which an assembly has been built?

我正在尝试查找程序集的 .NET 运行时版本。我查看了以下的两个最佳答案:Determine framework (CLR) version of assembly 但它们似乎没有报告正确的版本。

我正在机器 运行 .NET 4.6.1Visual Studio 中构建程序集该项目的目标是 .NET 4.5.1 但是,当我使用另一个问题的答案查看程序集时,我得到:

v4.0.30319

而不是

v4.5.1.*****

这是怎么回事?

改为查看官方 Microsoft 博客:

https://blogs.msdn.microsoft.com/rodneyviana/2014/12/23/identifying-the-net-version-you-are-running-2-0-4-5-4-5-1-or-4-5-2/

To make things more challenging, .NET 4.5, 4.5.1 and .NET 4.5.2 share the same version number as .NET 4.0 which is 4.0.30319. So, how can you tell which version you are running? You can use the same methods you used for .NET 2.0, except that the file of interest is rather clr.dll normally at C:\Windows\Microsoft.NET\Framework\v4.0.30319.

显然,区分差异的唯一方法是查看 clr.dll.

的内部版本号