Translate

Wednesday 21 May 2014

Assembly

What is a .NET assembly?

An assembly is the primary building block of a .NET application and can take the form of a dynamic link library (DLL) or executable file (EXE). An assembly is a collection of functionality that is built, versioned, and deployed as a single implementation unit.

What does an assembly contain?

A .NET assembly may contain the following elements:
  1. Assembly Manifest – Metadata that describes the assembly and its contents (see below)
  2. Source Code – Compiled into Microsoft intermediate language (MSIL)
  3. Type Metadata – Defines all types, their properties and methods,classes, interfaces, enums, structs and most importantly, public types exported from this assembly
  4. Resources – Icons, images, text strings and other resources
The assembly manifest is required; the other elements are optional.

What is an assembly manifest?

An assembly manifest is metadata inside an assembly that describes everything there is to know about the assembly and its contents. The manifest contains:
  • Strong Name – The assembly’s name, version, culture, optional processor architecture, and public key (for shared assemblies)
  • File Contents – Name and hash of all files in the assembly
  • Type List - Types defined in the assembly, including public types that are exported from the assembly
  • Resource List – Icons, images, text strings and other resources contained in the assembly
  • Dependencies – Compile-time dependencies on other assemblies
  • Security – Permissions required for the assembly to run properly
MISL code is executed through CLR (it cannot be directly executed)
 .NET 3 types of Assemblies are available,

it is classified as,

1. Private Assemblies
2. Shared Assemblies (public Assembly)
3. Satellite Assembly

Private Assemblies

A private assembly is used only by a single application and is stored in that application's directory other wise in the application's sub directory.

There is no version constraint in private assembly.


If an assembly is copied in to the respective application in which we would like to use is known as local assembly. if any changes made to the copy that will not reflect the copies in other applications.


 Public Assemblies


  • It resides in GAC, so that anyone can use this assembly. Public assemblies are always share the common.
  • It has version constraint.
  • This public assembly is stored inside the global assembly cache or GAC.GAC contains a collection of shared assemblies.
  • If an assembly is copied into the global place and reference is used from all other applications then this is called public or global assembly..if we want to copy assembly in global place we have to create strong name by using sn.exe.
Satellite Assembly

A satellite assembly is defined as an assembly with resources only, no executable code.

Satellite assemblies are used to build multi-linguistic applications. Application which has built in supportive of more than one human readable language is known as multi-linguistic applications.
  • Satellite Assemblies doesn’t contain any Data
  • Satellite assembly is containing cultural information.
  • Satellite assembly mainly used for to display information based on the Cultural setting of browser or region.

What is the difference between a private and shared assembly?

A private assembly is used only by a single application and is stored in that application's directory other wise in the application's sub directory. The name of a private assembly name must be unique within the application that uses it. There is no version constraint in private assembly. 
A shared assembly is used by multiple applications and is typically stored in a global folder known as the Global Assembly Cache (GAC). When building an assembly, a developer must specifically choose to build it as a shared assembly by giving it a cryptographically strong name. For example, the .NET Framework is a collection of shared assemblies.

What is the difference between an assembly and a namespace?

Namespaces are logical, whereas assemblies are physical.
A namespace is a logical naming scheme to group related types. Namespaces can contain other namespaces to form a hierarchy. The “fully qualified name” of a type is its namespace followed by its type name, separated by a period (for example, System.Windows.Forms.Button). Type names must be unique within a namespace, but the same type name can be used in different namespaces.
An assembly is a physical deployment scheme to group related types. An assembly can contain one or many namespaces. A namespace can exist in one or many assemblies.

What is the Difference between Assembly and DLL?

DLL is a dynamically linked library. Although, assemblies are physically equal to DLLs, they are very different internally. It is not possible to maintain consistency between a set of DLLs, but the CLR can maintain consistency between a set of assemblies, because assemblies are self-describing (they contain the list of dependencies internally). Unlike for DLLs, versioning information is enforced for assemblies (by the CLR). Side-by-side deployment (different applications using different versions) is possible with assemblies.








No comments:

Post a Comment