Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are framework dlls repeated in several places?

After installing .Net 4 and getting some questions that were already answered here I also realized how the Framework dlls are repeated in several places for the different Framework versions (this is not new, it happens with previous versions, but hadn't paid attention to it until now)

1 - GAC: %systemroot%\assembly

2- Framework installation directory: %systemroot%\Microsoft.NET\Framework\v...

3- and if you have the Windows SDK installed, also in: C:\Program Files\Microsoft SDKs\Windows\

I think the last ones are the so called "Reference Assemblies" and have extra metadata to aid Visual Studio, but

what about location number 2? Why are assemblies repeated there?

like image 790
Xose Lluis Avatar asked May 17 '10 17:05

Xose Lluis


People also ask

Where are .NET framework DLLs stored?

NET in the File System. You can check your installed versions of . NET by navigating to Microsoft.NET\Framework under your Windows folders. The complete path is usually 'C:\Windows\Microsoft.NET\Framework.

What's the purpose of a DLL in Windows?

The use of DLLs helps promote modularization of code, code reuse, efficient memory usage, and reduced disk space. So, the operating system and the programs load faster, run faster, and take less disk space on the computer. When a program uses a DLL, an issue that is called dependency may cause the program not to run.

What is a DLL and how does it work?

A dynamic link library (DLL) is a collection of small programs that larger programs can load when needed to complete specific tasks. The small program, called a DLL file, contains instructions that help the larger program handle what may not be a core function of the original program.

Where is the dynamic link library located?

Location of the *. dll File: The dynamic link library file must be placed either in the same folder as the project executable, or preferably in a directory pointed to by a PATH variable. For example, create a directory called C:\temp\my_dlls and place your *. dll files within it.


2 Answers

  1. No, that's the GAC location for .NET 1.x through 3.5. The GAC for 4.0 is located in c:\windows\microsoft.net\assembly. Why it was moved isn't clear, probably to avoid trouble with projects that referenced assemblies directly from the GAC, a big no-no but it has been done.

  2. Yes, reference assemblies live there. Also in c:\program files\reference assemblies. They are initially verbatim copies of the assemblies stored in the GAC. Until you deploy some kind of hotfix. Keeping them separate ensures that you build programs that target the "proper" framework assemblies, not what you happen to have stored in your GAC.

  3. Yes, no framework assemblies are there, just build tools.

like image 189
Hans Passant Avatar answered Nov 15 '22 04:11

Hans Passant


This is more of an educated guess than an actual answer but ...

In order to initially GAC a DLL you need to have a full DLL (aka not-reference assembly) for the GAC to use. The reference assembly won't work as it doesn't have executable code. Hence you need a real DLL in which to source the GAC so you get location #2.

like image 28
JaredPar Avatar answered Nov 15 '22 04:11

JaredPar