May 7, 2010

Dotnet Framework Basics

 

Microsoft .NET Framework

========================

 

.NET Framework = Base class Library(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

Econo-JIT

Normal-JIT

 

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

 

Assemblies

----------

- 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

                [assembly:AssemblyKeyFileAttribute("myKey.snk")]

                [assembly:AssemblyDelaySignAttribute(true)]

- Ex:

                using System;

                namespace SURComponents

                {

                                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().

 

Garbage Collector

-----------------

- 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

 

3 comments:

  1. SOLID Principles for Object Oriented Design

    1)A class should concentrate on doing one thing
    2)Change a class' behaviour using inheritance and composition
    3)Subclasses should behave nicely when used in place of their base class
    4)Keep interfaces small and cohesive
    5)Use lots of interfaces and abstractions

    well explained in http://www.davesquared.net/2009/01/introduction-to-solid-principles-of-oo.html

    ReplyDelete
  2. What is the difference between garbage collection and Dispose Method?

    Garbage collector automatically remove all unused objects by implicitly calling finalize () method but if you want to delete object forcefully (The larger object you want to delete after completing task) than you can explicitly call dispose () method.

    ReplyDelete
  3. What are the Unary operators?

    is a bitwise operator and it is "~"

    ReplyDelete