Thursday, February 26, 2009

.NET Framework(more to come)

. NET Framework:
The .NET Framework is an integral windows component that supports building and running the next generation of applications and web services.
It includes large library of coded solutions to prevent common problems and a virtual machine that manages the execution of programs. The key components of the .NET Framework are common language runtime (CLR) and the .NET Frame work class library, which includes ADO.NET, ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF). The .NET Framework provides a managed execution environment, simplified development and deployment, and integration with a wide variety of programming languages.

Common Language Runtime (CLR):
Is a runtime environment that manages the execution of .NET program code, and provides services such as memory and exception management, debugging and profiling, and security.
Responsibilities of CLR:
Garbage Collection: CLR automatically manages memory thus eliminating memory leaks. When objects are not referred GC automatically releases those memories thus providing efficient memory management.
Code Access Security: CAS grants rights to program depending on the security configuration of the machine. Example the program has rights to edit or create a new file but the security configuration of machine does not allow the program to delete a file.
Code Verification: This ensures proper code execution and type safety while the code runs. It prevents the source code to perform illegal operation such as accessing invalid memory locations etc.
IL (Intermediate language): To-native translators and optimizer’s CLR uses JIT and compiles the IL code to machine code and then executes. CLR also determines depending on platform what is optimized way of running the IL code.
Intermediate Language (IL): Is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In- Time (JIT) compiler.
You can also define IL as The system-independent code generated by a .NET language compiler. CIL defines a file format for storing managed code as both program instructions and metadata in a single file.

Common Type System (CTS):

It is the subset of CLS. It defines about how Objects should be declared, defined and used within .NET
Example: In VB you have “Integer” and in C++ you have “int” these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages can communicate Microsoft introduced Common Type System. So “Integer” datatype in VB6 and “int” datatype in C++ will convert it to System.int32 which is datatype.

Common Language Specification (CLS):
CLS is the guidelines that a language has to fallow in order to communicate with other .NET languages in a seeming less manner.
(OR)
It provides the set of specification which has to be adhered by any new language writer / Compiler writer for .NET Framework. This ensures Interoperability. For example: Within a ASP.NET application written in C#.NET language, we can refer to any DLL written in any other language supported by .NET Framework. As of now .NET supports around 32 languages.
Component Object Model (COM):
A software architecture developed by Microsoft to build-component based applications. They are language independent, have built in interprocess, communication capability, and easily fit into OOP design.
Managed Code:
Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.
Assembly:
It is called as building blocks of .NET Framework. All of the files that comprise a .NET application including the resources, security management, sharing deployment and actual MSIL code executed by CLR.
Types of Assemblies:
Private: A private assembly is normally used by a application, and is stored in the applications directory, or a sub-directory beneath.
Public/Shared: A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, Example crystal report classes which will be used by all application for Reports.
Satellite Assembly: when you write a multi-cultural application in .NET, and want to distribute the core application from the localized modules, the localized assemblies that modify the core applications are called satellite assemblies.

FAQS on Assembly:

1. How is the DLL Hell problem solved in .NET?
Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.

2. What are the ways to deploy an assembly?
An MSI installer, a CAB archive, and XCOPY command.

3. What namespaces are necessary to create a localized application?
System.Globalization & System.Resources.

4. What is the smallest unit of execution in .NET?
an Assembly.

5. When should you call the garbage collector in .NET?
As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.

6. How do you convert a value-type to a reference-type?
Use Boxing.

7. What happens in memory when you Box and Unbox a value-type?
Boxing converts a value-type to a reference-type, thus storing the object on the heap. unboxing converts a reference-type to a value-type, thus storing the value on the stack.
Namespace:
A logical grouping of the names (i.e., identifiers) used within a program.
Difference between Namespace and Assembly
• Assembly is physical grouping of logical units. Namespace logically groups classes.
• Namespace can span multiple assemblies.
Metadata:
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things (See Figure Manifest View for more details):
• Version of assembly
• Security identity
• Scope of the assembly
• Resolve references to resources and classes.
• The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
Global Assembly Cache (GAC):
A reserved area of memory used to store the assemblies of all of the .NET applications running on a specific machine. Is used where shared .NET assembly reside. GAC is used in the following situations
• If the application has to be shared among several application.
• If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.

1 comment:

 
Computers Business Directory - BTS LocalAdd to Technorati Favorites