Sunday, December 24, 2006

SOME LOW LEVEL CONCEPTS

People who work on MS.NET technologies are pretty much clear about the technical facts that MS.NET follows but very few are sure of the LOW LEVEL CONCEPTS that MS.NET is based on. Through this article I am targeting those types of developers, Professionals and of course learners.

Let’s start with a very simple “Hello world” Program here. What we do, open a notepad, write the program and save it to some location. (People who use Visual studio.net can use the templates provide by Microsoft for creating simple console application).

Let’s say I have written a program “HelloWorld.cs” and saved it to “C: Drive”. Let me tell you the steps what happens one by one. After saving the program the next step is to compile the program using some compiler, in our case the program is written in C# so we will use a C# compiler. It does make any difference in which language we write program for compiler, e.g. if we write program in C#, we have to use C# complier and same for VB, J#, Python etc.

After compilation process, regardless of which compiler we use, the result is a managed module. A managed module is a standard 32 bit Microsoft Windows Portable Executable (PE32) or a standard 64 bit windows portable executable (PE32+) file. This means that if we are targeting 32 bit platforms then the result will be PE32 file and PE32+ for 64 bit platforms like Windows XP 64 bit operating systems.

Now after compilation process, we got the managed module. I must tell you, what we have in these PE files.

The first stuff that PE (Managed Module) contains is the PE header, which can be PE32 (if file is targeted to run both on Windows 32 bit or Windows 64 bit versions) or PE32+( if file is targeted to run only on 64 bit versions of windows). This header also includes the type of file, which can be GUI (Graphical User Interface), CUI(Character User Interface) or DLL(Dynamic Link Library) and also a timestamp which tell us that when the file was built.

The second stuff is the CLR Header, before telling you about CLR header, let me clear you the fundamentals of CLR, CLR stands for Common Language Runtime, as the name suggests it is the runtime that is used by different and varied programming language, CLR has no idea which programming language the developer used for the source code. Fair enough about CLR, now come to the point, i.e. concept of CLR header. It contains the information that makes the managed module a managed module.

The CLR header includes.
(a) Version of the CLR required
(b) Some Flags
(c) Main Method
(d) Location and size of the
a. Managed Module metadata
b. Resources
c. Strong Name
d. Some Flags
e. And other less interesting stuffs


The third stuffs that Managed module contains are the METADATA.

There are two main types of tables in.
(a) Tables that describe the types and members defined in “HelloWorld.cs”
(b) Tables that describe the types and members referenced by our source code i.e. “HelloWorld.cs”

The fourth stuff that we have in Managed module is INTERMEDIATE LANGUAGE CODE also called MSIL or shortly IL Code or sometimes MANAGED CODE because CLR manages its execution. This is the code that compiler produces as it compile the source code.

One or more managed modules with Resource files (Optional) are converted to assemblies which also contains MENIFEST other than these stuffs. It is ASSEMBLY that is targeted by CLR for execution.

Hope you are bit clear with the fundamentals of MANAGED MODULES. Comments will be highly appreciated.

1 comment:

HR Insight_Dharmendra said...

The scholar had good command over MS.NET in context of its functionality and practicality,In some last blogs, he has been a part of MS.NET discussion with other application..so,overall it shows scholar's insight as well as forsight & by writing this type of intellectual blog,he compels the all technocrats towards innovative way of practices to meet future demand and services....
welldone, GO AHEAD>>>>>