Sunday, July 17, 2016

Assembly

Assembly

Assembly form the fundamental unit of deployment, version control, reuse.
Assembly take the form of an executable (.exe) file or dynamic link library (.dll) file. They provide the CLR with information it needs to be aware of type implementation.
You can think of an assembly as a collection of types and resources that forms a logical unit of functionality and are built to work together.



Assembly Contents
1. Assembly manifest which contains metadata
2. Type metadata
3. MSIL code that implements the type
4. Set of resources

Assemblies have the following properties

  • Assemblies are implementated as .exe or .dll files
  • You can share an assembly between applications by putting in the GAC. Assembly must be strong-named before they can included in GAC
  • Assemblies are only loaded in the memory if they are required. if they are not required they are not loaded
  • You can problematically obtain information about an assembly by using reflection.

Assembly Manifest

Within every assembly is an assembly manifest.
Assembly manifest contains the following

  • The assembly identity (its name & version) make up the assembly for e.g. any other  assemblies you created that your .exe or .dll relies on
  • An assembly reference list - External dependency such as GAC or somewhat like system 32 directory.

Assembly Contents

In general, a static assembly can consists of four elements.
  • The assembly manifest, which contains assembly metadata
  • Type metadata
  • Microsoft Intermediate Language (MSIL) code that implements types
  • A set of resources

Metadata

Metadata is a binary information describing your program that is stored either in a common language runtime portable executable (PE) file or in memory. When you compile your code into PE file, metadata is inserted into one portion of the file and your code is converted to Microsoft  intermediate language (MSIL) and inserted into another portion of the file.
Every type and member that is referential in a module or assembly is described within metadata. When code is executed, the runtime loads metadata into memory and references it to discover information about you code's classes, members , instances and so on.

Language interoperability : Metadata provides all the information required about compiled code for you inherit a class from a PE file written in different language you can created an instance of any class written in any managed language (any language that targets the common language runtime) without worrying about explicit marshaling or using custom interoperabilty code.

MSIL
When compiling to managed code, the compiler translates your source code into MSIL, which is CPU independent set of instruction that can be efficiently converted to native code. Before code can be run, MSIL must be converted to native code, usually by a Just-In-Time (JIT) compiler


No comments:

Post a Comment