How to identify that an assembly has been compiled with/for .NET 4.5, as opposed to .NET 4.0?

▼魔方 西西 提交于 2019-12-01 04:39:46
Hans Passant

Run ildasm.exe and look at the manifest. You'll see the TargetFrameworkAttribute:

.custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = 
( 01 00 1A 2E 4E 45 54 46 72 61 6D 65 77 6F 72 6B   // ....NETFramework
  2C 56 65 72 73 69 6F 6E 3D 76 34 2E 35 01 00 54   // ,Version=v4.5..T
  0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73 70 6C   // ..FrameworkDispl
  61 79 4E 61 6D 65 12 2E 4E 45 54 20 46 72 61 6D   // ayName..NET Fram
  65 77 6F 72 6B 20 34 2E 35 )                      // ework 4.5

The CLR uses this attribute to verify that the correct version is present on the machine, prompting the user to get it automatically installed if it is not.

The metadata version v4.0.30319 is for .Net 4.0. See here:

Generation Version number

1.0 - 1.0.3705

1.1 - 1.1.4322.573

2.0 - 2.0.50727.42

3.0 - 3.0.4506.30

3.5 - 3.5.21022.8

4.0 - 4.0.30319.1

4.5 - 4.5.50709.17929

4.5.1 - 4.5.50938.18408

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!