Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find which mscorlib.dll a program is using?

Tags:

c#

.net

I have installed a 3rd party program on my computer. I opened up one of the .dll's that comes with this program in ildasm.exe and inspected the manifest:

.assembly extern mscorlib
{
   .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )              // .z\V.4..
   .ver 2:0:0:0
}

So the program uses either .net 2.0, 3.0 or 3.5.

I searched for mscorlib.dll on my computer and found 61 files.

How do I find which of these .dll's the program is actually using?

I also notice that a bunch of these are in directories named: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\ProfileXXX\mscorlib.dll, where XXX is a 1-3 digit number.

What is going on here? I could understand that each .net version (2.0, 3.0, 3.5 ...) would have a different file but that should not add up to 61 files. What is the difference between each of these profiles?

Is this what the .net solution of the .dll hell problem looks like? A whole lot of versions of the same file + public keys to safely indentify the .dll.

Who deletes the .dll's that are no longer used? It seems that potentially every program has its own version of .net. Must fill up the disk eventually?

like image 710
Andy Avatar asked May 22 '15 13:05

Andy


People also ask

Where is Mscorlib dll located?

Search for all the Mscorlib. dll files in the %systemroot%\Microsoft.NET\Framework folder and the %systemroot%\Microsoft.NET\Framework64 folder if the folder exists. Click on each of the files, view properties, and click version tab to determine the version installed.

How can I see the details of a dll?

To view DLL propertiesSelect the desired DLL and right-click the file. Click Properties and Version.

What is Mscorlib dll file?

NET Framework, MSCorLib. dll was an acronym for Microsoft Common Object Runtime Library. Once ECMA started to standardize the CLR and parts of the FCL, MSCorLib. dll officially became the acronym for Multilanguage Standard Common Object Runtime Library."


1 Answers

You just discovered a simple fact, .NET has been very popular and after 13 years there are a lot of versions of it. Most programmers know about version 1.0, 1.1, 2.0 and 4.0 for the desktop version. And it is always pre-jitted by NGEN so multiply by 2. Most don't know that mscorlib.dll contains unmanaged code so there are two distinct versions of it, one for 32-bit and one for 64-bit code, multiply by 2 again.

That's just for the desktop. Then you have the versions that target different runtime environments. There's Silverlight, 5 distinct versions. Windows Phone, 4 versions. Windows Store, 2 versions. And XBox. They matter because you can build programs that run on these targets.

Then there's Portable Class Libraries, they allow you to select the set of targets you want to support. Each permutation of choices has its own distinct reference assembly so you can't accidentally use a type that won't be available on one of the targets.

So the real surprise here is that you found so few of them.

Do keep in mind that the vast majority you found are only reference assemblies. They just contain metadata, no code, present in the c:\Program Files (x86)\Reference Assemblies directory. You only use them when you build your program. At runtime the "real one" gets used, it is very different from the one you built with. It is Microsoft's burden to ensure that they match and you won't have a problem, they are very good at it.

There is otherwise nothing special about the one you listed. It asks for the v2.0 version, the one used in .NET Framework version 2.0 through 3.5. Even if you don't have one of those versions installed on your desktop, you can still run it if you have 4.0, 4.5 or 4.6. The desktop CLR automatically translates requests for 2.0.0.0 to the 4.0.0.0 version, it is very compatible.

like image 102
Hans Passant Avatar answered Oct 06 '22 00:10

Hans Passant