简体   繁体   中英

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

I am trying to find the .NET runtime version of an assembly. I have looked at the two top answers of the: Determine framework (CLR) version of assembly but they do not seem to report the correct version.

I am building the assembly on a machine running .NET 4.6.1 and in Visual Studio the project is targeting .NET 4.5.1 however when I look at the assembly using the answers on the other question I get:

v4.0.30319

Instead of something along the lines of

v4.5.1.*****

What is going on?

Take a look at official Microsoft blog instead:

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.

Apparently, the only way how to tell the difference is by looking at build number of clr.dll .

内部版本号映射到版本

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM