Tuesday, May 12, 2015

.NET Framework References (pt. 4) – Sizes and Locations of Versions 4.x


Visual Studio manages the .NET Framework assembly references well on a project basis.  It is automatic but also brings about confusions in some situations.
As discussed earlier, the .NET Framework versions 4.0 and later, such as 4.0, 4.5, and 4.5.1 has a single place, a version specific sub-folder (v4.0.30319), under the Windows .NET Framework location:
C:\Windows\Microsoft.NET\Framework\v4.0.30319
However, under the Reference Assemblies .NETFramework location of the Program Files (x86) directory, there are all the three flavors:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework

The v4.x version specific .NET Framework assemblies such as the System.Windows.Forms.dll that are referenced by the Visual Studio Reference Manager are pointing to these locations now, instead of the Windows .NET Framework location, as also mentioned before.
In this post, we are going to explore a bit deeper about these.  A simple question: why is the version specific folder v4.0.30319 necessary in the Windows .NET Framework directory?
Let’s check the properties (especially the Size) of the System.Windows.Forms.dll first:
            The size of the same assembly but in different folders under the Program Files (x86) next:




             As can be seen, all the four versions of the same assembly have different sizes, which are as expected.  However, the interesting point is that the size of the v4.0.30319 one is more than the total size of the other three.  Let’s do an exact math calculation here.
1,637,736 + 1,507,344 + 1,507,456 =  4,652,536 bytes
4,850,384 – 4,652,536 = 197,848 bytes
            So, some educational guess could be made here, we believe.  The Windows .NET Framework v4.0.30319 assembly is the host of all other flavors deployed to the Reference Assemblies folders under Program Files (x86).  The extra around 200 KB in the host is obviously used to index all the three versions?

No comments:

Post a Comment