Wednesday, 3 March 2010

FAQ's - DotNet Framework

What is CLR? Who loads the CLR into a process?

Common Language Runtime - It is the implementation of CLI(Common Language Infrastructure). The core runtime engine in the Microsoft .NET Framework for executing applications. The common language runtime supplies managed code with services such as cross-language integration, code access security, object lifetime management, resouce management, type safety, pre-emptive threading, metadata services (type reflection), and debugging and profiling support. The ASP.NET Framework and Internet Explorer are examples of hosting CLR. The CLR is a multi-language execution environment. There are currently over 15 compilers being built by Microsoft and other companies that produce code that will execute in the CLR. 
The CLR is described as the "execution engine" of .NET. It's this CLR that manages the execution of
programs. It provides the environment within which the programs run. The software version of .NET is
actually the CLR version.

What is an Application Domain?Application domains help in providing isolation, unloading, and security boundaries for executing managed code. These Application Domains are very similar to the operating system concept Process. The isolation of applications is achieved using Application Domains. This will help them to see that they do not affect each other.

What is a GC?In C#, Garbage Collector will collect variables(Weak & no reference objects) from generations. Initially, when a variable is declared, it will be into generation 0, When GC is collecting variables for garbage collection, it will move all variables which are uncollected to its higher generation. So, all uncollected variables in Generation 0 will move to Generation 1 and Generation 1 variables to Generation 2. Currently Garbage collector has 3 generations, Generation 0,Generation 1 and Generation 2.You can find maximum number of generations that CLR will have by using1.System.GC.MaxGeneration

What is a CTS and CLS?
• CTS (Common Type System)It defines “How object should be declared”. CLS is the subset of CTS.


• CLS (Common Language Specification)It provides, set of specification TO BE adhered by new language writer/compiler writer for .Net Framework to ENSURE interoperability. ‘cause .net supports 32 languages.For example Asp.Net application written in C#.Net language. Now we can refer any other DLL which has been written in any other language supported by .Net Frame Work.

What is GAC?The Global Assembly Cache (GAC) stores assemblies specifically designated to be shared by several applications on the computer. Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. GAC physically creates directories for each version of the assembly. The Global Assembly Cache (GAC), when viewed using Explorer, has its view rendered in a special manner by the OS shell. When an Assembly is added to GAC these are the attributes that it takes.
• Assembly Name – Name of the Assembly
• Version – Version [Major-Minor-Revision-Build]
• Culture – Culture will be null for normal Assembly
• Public Key Token - This is a 64-bit hash of the public key which makes the assembly name unique.
• Processor Architecture – Either MSIL or x86

What is an Assembly?
An assembly is a basic building block for any application in the .NET Framework. It is a fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the Common Language Runtime (CLR) with the information it needs to be aware of type implementations. During runtime, a type does not exist outside the context of an assembly.
The contents of an assembly are the following.
• CIL – Common Intermediate Language (formerly MSIL - Microsoft Intermediate Language)
• Assembly Manifest – The Assembly Manifest has the information like Name, Version number, Culture, Strong Name information, etc.
• Type Metadata
• Resources

What are the different types of assemblies?
1) Private Assembly
2) Public/Shared Assembly
3) Satellite Assembly

What is a Shared Assembly?
Shared Assemblies are kept in Global Assembly Cache. Client application using Shared Assemblies need not have its own copy of dll. Shared Assemblies are present in C:\WINDOWS\assembly folder.
Steps to create Shared Assembly:
1. Create a .dll file. (Here i am using my existing HappyNewYear.dll)2. Now let me create unique assembly name using SN utility(Shared Name utility).  The syntax for it is: sn -k filename.snk
Here sn stands for strong name, -k stands for key and key is stored in filename.snk .


What is a Satellite Assembly?
Satellite Assembly is a .NET Framework assembly containing resources specific to a given language. Using a satellite assembly, we can place resources of different languages in different assemblies and the correct assembly is loaded into memory only if the user elects to view the application in that language.

What is a .NET module? How is a .NET module different from an Assembly?
A .NET module is a portable executable file of type.dll or .exe consisting of one or more classes. This is similar to a .NET assembly which consists of classes, namespaces, etc.
A .NET module can not be deployed alone. It has to be linked into an assembly. This can be done by using compiler’s /add module switch (if the compiler supports it), al.exe, or in .NET Framework 2.0, link.exe.

What is CodeDOM in .NET used for?
CodeDOM is an API that helps in creating and compiling a programming structure at Runtime. Creating a programming structure involves creation of Namespace, Type – Class, Interface and even methods at the Runtime. The implementation of CodeDOM can be divided in the two ways shown below. The namespace for the CodeDOM is System.CodeDOM.
• Compiling or Building the Programs at the Runtime
• Using CodeDOM for generating a Program structure

Meaning for Assembly Version?
1:2:3:4 -- (Major : Minor : Build : Revision)

Install/Uninstall the assembly in GAC or converting a private assembly as a shared assembly?
Ex: gacutil /i assemblyname.dll (Add)
gacutil /u assemblyname.dll (Add)

5 comments: