Question

I am trying to use the microsoft reference source but ran into problems. As per their suggestion for troubleshooting I tried to validate that I am using the right .NET framework version. ildasm however shows this:

enter image description here

I did however change the target framework of the project as you can see here:

enter image description here

Do I need to change the version somewhere else?

Was it helpful?

Solution

What you got is accurate. A project that targets .NET 4.5 or 4.5.1 still uses CLR version 4.0.30319 and core framework assemblies like mscorlib v4.0.0.0

This is largely a repeat with what happened for .NET versions 3.0, 3.5 and 3.5SP1, they target CLR version 2.0.50727 and core framework assemblies v2.0.0.0. Just like 4.5 and 4.5.1, they were not new side-by-side versions. They just added new assemblies to the existing set.

You can still tell what target you have selected with ildasm.exe, look at the System.Runtime.Versioning.TargetFrameworkAttribute attribute you see in the metadata. The CLR checks this to ensure you are not trying to run a 4.5.1 on a .NET 4.0 or 4.5 install. Offering to download the version you need. It looks like this (edited for readability):

 .custom instance void [mscorlib]System.Runtime.Versioning.TargetFrameworkAttribute::.ctor(string) = 
( 01 00 1C 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 2E 31 01   // ,Version=v4.5.1.
  00 54 0E 14 46 72 61 6D 65 77 6F 72 6B 44 69 73   // .T..FrameworkDis
  70 6C 61 79 4E 61 6D 65 14 2E 4E 45 54 20 46 72   // playName..NET Fr
  61 6D 65 77 6F 72 6B 20 34 2E 35 2E 31 )          // amework 4.5.1

OTHER TIPS

If you are trying to determine .Net framework version from Metadata version, then it is not the right way.

Metadata version shows the runtime version or CLR version.

the .NET Framework 4, 4.5, and 4.5.1 include CLR 4, but the .NET Framework 2.0, 3.0, and 3.5 include CLR 2.0. (There was no version 3 of the CLR.)

So for .Net framework 4, 4.5 and 4.5.1 you will see the same CLR version i.e. V4.0.30319. You may see this answer for identifying .Net framework version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top