Learn IT

Free learning anything to everything in Information Technology.

Microsoft .Net Assemblies

Introduction
  • Assembly is a small unit of Code for Deployment
  • The basic building block for Dot Net Framework is an Assembly
  • Assembly can be an exe or dll file
  • But the difference between dll and exe is exe is an executable file
  • Dll is a reusable component.
  • Exe is a Stand alone application that can run on its own
  • Dll is used in other applications
  • Assembly is Collection of Data Types, Namespaces and Resources Information
  • Namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

The Four Main Parts

The main Parts of the Assembly are

  1. Manifest
  2. Type Meta Data
  3. MSIL Code
  4. Resources

Manifest

It will describe the assembly it will contain all the files information required for the assembly. These files includes all the other assemblies required for the application. It will be prepared by the complier by providing set of built in libraries and custom libraries provided with reference. This is required for the runtime to load the files at the time of execution Public key with Version number are stored here.

Meta Data

It will provide information about all the user defined types available with assembly

  • Includes
  • Namespace name
  • Class names
  • Interface names
  • Method names

This Meta data is required for the user of the assembly to access methods and classes.

IL Code

The source code in Dotnet is Compiled into IL code with the help of JIT complier in CLR .This code is responsible for Language independency, Architecture independency, Plat form independency and Security.
VS Command Prompt c :\> ildasm app.exe
File-->new-->open any dll from your existing web application
Double Click on manifest to examine manifest
You will find public key token with version number that is generated for Assembly
The expanded tree view of name spaces and classes methods is called Meta data
Try to examine Meta data MSIL/IL code that is generated for each method
MSIL IL code is in Assembly language it ‘s understands by only JIT Complier with the help of jitters inside it.
Double Click on Any Method Source code Converted to IL Code
// Code size 12 (0xc)
.maxstack 2
IL_0000: ldarg.0
IL_0001: callvirt instance string Infragistics.WebUI.CalcEngine.RefBase::get_NormalizedAbsoluteName()
IL_0006: callvirt instance int32 [mscorlib]System.String::GetHashCode()
IL_000b: ret
} // end of method RefBase::GetHashCode
This is the MSIL code starts with IL
If we can write code in IL code and understand it we can develop our own complier in the corresponding language.
There are around 30 third party language compliers available like COBOL.net,C#.net etc.

Resources

If assembly using any gif/image files that information is stored in resource section of the assembly. Note: To Examine the Components of the Assembly use Intermediate Language Disassembler (ILDASM) Go to
VS Command Prompt and type ILDASM
File -->Open the Dll
We can see the Manifest Meta Data ,IL Code Public key version number
This information can be helpful in determining whether a file is an assembly or part of an assembly, and whether the file has references to other modules or assemblies.

Advantages of .Net Assemblies

  1. No dll Hell
  2. Platform independency
  3. Inheritance is supported

0 comments: