Programs and libraries for .NET are packaged into units called assemblies
An Assembly is a logical unit of code. It physically exists as DLLs or EXEs,it can contain one or more files. The Assembly can contain Images ,Text files etc along with DLLs and EXEs.hence it is also defined as a versioned, self-describing binary (DLL or EXE) containing a collection of types (classes, interfaces, structs, and so on) and optional resources
Assembly is nothing but ,when you compile your source code by default DLLs or EXEs are generated by Assemblies. We can use our assembly after bundling our code. The version of the component is the version of the assembly to which the component belongs.
Every assembly file contains information about itself which is called as
Assembly Manifest is a data structure which stores information About Assembly.
The following information is stored in Assembly Manifest
- Assembly Name
- Version Number
- Strong Number Information
- List of All Files in the Asembly
- Type Reference
- Assembly Reference List
The assembly which is used only by a single application is called as private assembly.
For example if you created a DLL which encapsulates your business logic. This DLL will be used by your client application only and not by any other application. In order to run the application properly your DLL must reside in the same folder in which the client application is installed. Thus the assembly is private to your application.
Suppose that you are creating a general purpose DLL which provides functionality which will be used by variety of applications. Now, instead of each client application having its own copy of DLL you can place the DLL in 'global assembly cache'. Such assemblies are called as shared assemblies.
Global Assembly Cache
Assemblies can be located anywhere on your system. The .NET Framework maintains a special location on your system where assemblies can be stored so that they can easily be found by all .NET programs on the system. This location is called the Global Assembly Cache (GAC),
Global assembly cache is nothing but a special disk folder where all the shared assemblies will be kept. It is located under <drive>:\WinNT\Assembly folder.
Prior to .Net ,Developers generally faced DLL hell , we also generally hear about DLL Hell ,many of us don’t know about DLL Hell also,yes what is DLL Hell?
DLL hell is a colorful term given to any problem based on a difficulty in managing Dynamically Linked Libraries (DLLs) installed on a particular copy of an operating system. This includes conflicts between various versions of these libraries, difficulty in obtaining a large number of such libraries, and/or having many unnecessary copies of different versions.
This problem is existed more in COM Applications.
This headache is not there in Assemblies,let us see how it is solved
We already discussed that most of our Assemblies are Private, Hench each application refer it assemblies from it own installation folder, by this there will no conflict of multiple versions of same assembly.
All Assemblies have a version number. The version Number of Assemblies generally took the following form
when we change the original assembly the changed version will be compatible with the existibg one , if the major and minor versions of both the assemblies match.
When the application requests an assembly the requested version number is matched against available versions and the version matching major and minor version numbers and having most latest build and revision number are supplied.
The main advantage of using ASP.NET Assemblies is that developers can create applications without interfering with other applications on the system. When the developer creates an application that requires an assembly that assembly will not affect other applications. The assembly used for one application is not applied to another application. However one assembly can be shared with other applications. In this case the assembly has to be placed in the bin directory of the application that uses it.
This article tells us what is an Assembly in Asp.net.