.NET Framework = Base class Libray(BCL) + CLR
CLR - provides Memory management, Thread management, Exception handling, Garbage collection, Security.
BCL - user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications.
Source Code(C#) -------------> MSIL (or) CIL ----------------------------> Native Code
C# compiler CLR using JIT compiler
Types of JIT compiler
Pre-JIT :- Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
Econo-JIT :- Econo-JIT compiles only those methods that are called at runtime.However, these compiled methods are removed when they are not required.
Normal-JIT(default) :- Normal-JIT compiles only those methods that are called at runtime.These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.
CTS & CLS
- CLS is a subset of CTS
- Common Type System (CTS) describes how types are declared, used and managed in the runtime and facilitates cross-language integration, type safety, and high performance code execution.
- Common Language Specification (CLS) is nothing but guidelines that a language to follow so that it can communicate with other .NET languages in a seamless manner
- an assembly is a partially compiled code library for use in deployment, versioning and security
- an assembly is an EXE or DLL
- Private and Shared assemblies
- Private assemblies are stored along with the applicaton folder
- Share assemblies are stored in GAC.
- ILDASM is used to view assembly. It shows manifest and metadata.
- Manifest contains version, scope, security, references to resources and classes.
- Metadata is data about data and it contains information about classes, structs, interfaces, namespaces, etc.
- To create strong name sn -k "c:\temp.snk" to uniquely identify the assembly in GAC.
- Delay Signing : To avoid showing the strong names to developer during development
public class Sample
public string GetData()
return "hello world";
In the above example SURComponents assembly is created. We can import this assembly and create an object for the class Sample to use the method GetData().
- Three generations Generation0, Generation1, Generation2.
- Gen0 contains all the newly created objects and it is in the top of heap. Gen1 contains all the living objects from Gen0 and in the middle of heap. Gen2 contains all the living objects from Gen1 is in the bottom of heap.
- GC is able to collect the garbage in two ways: full collections (searching the entire managed heap for dead objects) and partial collections (searching only a single generation zone).
Access to COM components is provided in the System.Runtime.InteropServices and System.EnterpriseServices namespaces of the framework