The .NET Framework & CLR : Basic Introduction


The .NET Framework is Microsoft's answer to the JAVA platform. With heavy investments going into the development, one can't question the push Microsoft is giving to this technology. Living in the hi-tech industry and not interacting with the .NET Framework is highly unlikely, considering the market share that Microsoft's Operating Systems have. I am writing this article as a means to further the knowledge that I would be gaining while learning the MCAD Training Kit (maybe in the process, helping out some beginners). For those of you who don't know what the MCAD is, its one of the certification program offered by Microsoft. Short for Microsoft Certified Application Developer, the MCAD is aimed at developers. The MCAD I would be trying, is for the .NET Framework. For further information on Microsoft's certificaltion programs, check out the following links:- 


The .NET Framework
Basically the .NET Framework is comprised of two components: The CLR and the .NET Class Library. CLR stands for Common Language Runtime and allows the interoperability between the various .NET languages. The class library is comprised of a lot of reusable components (Classes, Functions, Methods etc) that aid us in doing common repetitive operations.

The CLR
The CLR sweeps away the traditional concept of the Application having to manage everything from Memory Allocation & Garbage Collection to Thread Management. The .NET Framework is responsible for performing the above mentioned operations. Its another excellent move as developers can now focus on matters concerning the application's logic without having to waste time on managing these iterative issues.

What’s with the multiple programming languages?
Developers using Microsoft Application Development Tools, could be natively put into two categories - those from the C/C++ background and those with the history of the BASIC language. Packed with a lot of punch & power, C/C++ was the choice for making advanced programs. But it had its shortcomings too, most noticeably the complexities involved with the language itself. Case Sensitivity and type strictness are a few of them to be named. While these measures minimize the potentially dangerous bugs that would take us hours to determine and debug, they are annoying to some developers. BASIC was aimed at being a friendly, English like language that could be understood and mastered by the average human. Originally it was way behind its counterpart in terms of power, but with time it has been catching up.

With introduction of the CLR based .NET Framework, Microsoft has instilled the freedom of language to the developers. Developers with expertise in different .NET languages can now work together in projects, thus increasing productivity.

The .NET Languages
Apart from those offered by Microsoft - VB, C# & C++ there are other languages that target the .NET Framework. COBOL, PERL, FORTRAN are just a few to name. All .NET Languages follow the Common Language Specification (CLS) to facilitate this.

How does the Interoperability work?
Programs written in .NET Languages are not compiled to machine code, rather into an Intermediate Language known as MSIL (Microsoft Intermediate Language) or just IL. So, any assembly written in the .NET languages, are the same internally. This implies that the atomic data types such as Integer, Float, etc are now the same in VB, C# & C++. The

Because of being compiled to MSIL, the reverse engineering of code becomes easier for .NET assemblies. It can seriously compromise security of a program, but thankfully there are obfuscation techniques to overcome it. Microsoft Visual Studio 2005 ships with a lite edition of dotfuscator. There are various other Obfuscators available in the market too.

Basic Structure of a .NET Application
.NET applications are comprised of assemblies. An assembly is a self-descriptive collection of codes, resources and metadata. Each assembly has a manifest which provides information pertaining to the assembly viz Assembly naming & versioning, list of all types exposed by the assembly, dependency on other assemblies & code security instructions. The manifest can exist externally or internally within a module of the assembly.

Compilation & Execution
As mentioned before, the .NET applications are compiled to the MSIL. During runtime, the MSIL is compiled into native binary code by the Just In Time (JIT) compiler. When the execution begins, the starting assembly is loaded and its manifest is validated. After all the security requirements are met, the assembly is executed. An important feature of the JIT compiler is that only the execution path of the assembly is compiled, thus maximizing performance.