Thursday, 5 June 2014

Assembles in C#.Net

An assembly is a collection of types and resources that forms a logical unit of functionality.
 
When you compile an application, the MSIL code created is stored in an assembly 
Assemblies include both executable application files that you can run directly from Windows without the need for any other programs (these have a .exe file extension), and libraries (which have a .dll extension) for use by other applications.
 
There are two kind of assemblies in .NET;
  • private
  • shared
 
Private assemblies are simple and copied with each calling assemblies in the calling assemblies folder.
 
Shared assemblies (also called strong named assemblies) are copied to a single location (usually the Global assembly cache). For all calling assemblies within the same application, the same copy of the shared assembly is used from its original location. Hence, shared assemblies are not copied in the private folders of each calling assembly. Each shared assembly has a four part name including its face name, version, public key token and culture information. The public key token and version information makes it almost impossible for two different assemblies with the same name or for two similar assemblies with different version to mix with each other.

more details to understand it....

Assembly is the smallest unit of deployment of a .net application. It can be a dll or an exe.
 
There are mainly two types to it:
 
Private Assembly: The dll or exe which is sole property of one application only. It is generally stored in application root folder
 
Public/Shared assembly: It is a dll which can be used by multiple applications at a time. A shared assembly is stored in GAC i.e Global Assembly Cache.
 
GAC is simply C:\Windows\Assembly folder where you can find the public assemblies/dlls of all the softwares installed in your PC.
 
There is also a third and least known type of an assembly: 
 
Satellite Assembly:A Satellite Assembly contains only static objects like images and other non-executable files required by the application.
 
Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata. An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information.
 
Assembly name:
 
A text string specifying the assembly's name.
 
Version number
A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.
 
Culture:
Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or language-specific information. (An assembly with culture information is automatically assumed to be a satellite assembly.)
 
Strong name information:
The public key from the publisher if the assembly has been given a strong name.
 
List of all files in the assembly:
A hash of each file contained in the assembly and a file name. Note that all files that make up the assembly must be in the same directory as the file containing the assembly manifest.
 
Type reference information:
Information used by the run-time to map a type reference to the file that contains its declaration and implementation. This is used for types that are exported from the assembly.
 
Information on referenced assemblies:
A list of other assemblies that are statically referenced by the assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

No comments:

Post a Comment