Pages

Thursday, 23 June 2011


                            -::.NET FRAMEWORK::-

Querry?? What is .NET?(.NET Framework)
.NET is a new Environment for Developing and Running software Applications, featuring ease of Development of Web based Services, rich standard runtime services available to Components written in a variety of Programming Languages and Inter language interoperability.
Querry?? What is .NET Framework?
.NET Framework is a set of Technologies that are designed to transform Internet into a full-scale distributed Computing Platform.
Querry??  What are the new Technologies in .NET Framework? Or
What .NET Framework consists?
.Net Framework Consists of Two main Parts.
a).Common Language Runtime(CLR)
b) .NET Framework Class Library
Querry?? What is CLR?
CLR is a set of Standard Resources responsible for execution of Code developed using .NET Languages.
CLR is a Replacement to win32 API.
Querry?? What CLR do?
CLR take care of
1.Memory Management
2.Thread Execution
3.CodeExecution
4.Code Safety Verification
5.Compilation
6.Automatic Garbage Collection
7.Very High Level Of Security while Executing

It Provides Cross-Language Inheritance and abilty to compile once and run on any CPU and OS that supports runtime through Compilers.

• Memory management. The CLR maintains a managed heap that is used for all memory allocations. The CLR also cleans up objects that are no longer used. Because of the information found in IL and Metadata, the CLR is able to enforce that references always refer to compatible types, null references are never accessed, instances are never referenced after they are freed, etc. This is one very important aspect of code management performed by the Common Language Runtime.
• Security. The CLR makes sure that code can not undermine a system if it is not trusted. An example of un-trusted code would be a binary that was downloaded and executed from a website. The great thing about managed code is that the un-trusted software still runs at full native speed. However, at the point of JIT-compiling, the CLR was able to insert enough code to assure that security cannot be breached. If the executable crosses the line, the CLR knows about it, and will raise a security exception. This will cause the unacceptable operation to fail.
• Thread management. Although you can create your own thread objects with managed code, the CLR maintains a thread pool which can be used by your software. The thread pool efficiently uses threads for asynchronous behavior, and then returns an unused thread to a queue until it is needed again.
• Type safety. It is impossible for managed code to coerce a type into an incompatible type. At runtime the CLR checks all typecasting operations to be sure that the cast is valid. Because managed code uses references to objects in a managed heap (rather than pointers), it is also impossible to coerce one type to another through pointer manipulation. This drastically reduces bugs, and removes the fear that third-party code might undermine the integrity of your system.
• Code verification. The CLR asserts certain truisms about managed code. For example, the CLR (by default) will not JIT compile code that references a variable before it has been assigned to. The CLR can also be made to JIT compile code so that numerical operations that overflow raise exceptions so that they can be caught (although this is not the default). The CLR also asserts that all methods must have a return instruction. It is impossible for one instruction to run-over into the next. Code verification is another feature that makes code robust, and makes it safe to run un-trusted or semi-trusted components.

Querry?? What Compiler do?
The compiler compiles the source code into Intermediate Language (Microsoft Intermediate Language),Which is language Independent. Then it is compiled to native machine code.
Querry?? What is Microsoft Intermediate Language(MSIL)?
MSIL or IL is the CPU Independent Instruction set that is generated by Microsoft .NET Framework Compilers and Consumed by .NET Framework’s Common Language Runtime.
Before MSIL can be executed, it must be converted to native CPU-Specific Code by Common Language Runtime.
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language).

Querry?? What is the CTS?
CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.
Querry?? What is the CLS?
CLS = Common Language Specification. This is a subset of the CTS, which all .NET languages are expected to support. The idea is that any program, which uses CLS-compliant types, can interoperate with any .NET program written in any language.
In theory this allows very tight interlope between different .NET languages - for example allowing a C# class to inherit from a VB class.
Performing Cross-Language Inheritance the Language Compilers must follow CLS.
CLS(Common Language Specification) describes a subset of Data types supported by Runtime, that are common to all of the languages used in .NET.
Querry?? What are Data Types available in .NET?

Data Type is an attribute that specifies the type of data that object can hold.
System.Boolean ? 1 byte
System.Byte ? 1 byte
System.Char ? 2 bytes
System.Int16 ? 2 bytes
System.Int32 ( 4 bytes
System.Int64 ( 8bytes
System.Object ( 4bytes
System.Single ( 4bytes
System.Double ( 8bytes
System.Decimal ( 12bytes
System.DateTime ( 8bytes
System.String ( 10bytes +(2*string length)
System.ValueType ( Sum of Member sizes(User Defined Type)

Querry?? What is UnManaged Code?
UnManaged Code is code that is executed directly by O.S, outside the Microsoft .NET Framework’s Common Language Runtime. Unmanaged code must provide its own memory management, typechecking and security support, unlike Managed code which receives these services from Common Language Runtime. Unmanaged code must be executed outside the .NET Framework

Querry??  What is Managed Environment?
A Managed Environment is one which the Environment Provides Services such as Garbage Collection, Security and Other Similar Features.
Querry?? What is Managed Code?
.NET Framework Provides Several Core Runtime Services to the Programs that run within it. For eg: Memory Management, Cross-Language Integration, Automatic Lifetime Control of Objects etc.
For these services to work the code must provide a minimum Level of Information to the Runtime. Such a Code is called Managed Code.
All C# and VB.NET code is Managed by Default.
Querry?? What are Managed Classes?
These are Classes that the memory for Instances of the class is Managed by Garbage Collector and the Class becomes a Fully Paid up member of .NET community with the benefits that brings.
Eg: Benefit is proper interop with classes written in Other Languages.
Restriction is that a managed class can inherit from one base class only.
Querry?? What is an Assembly?
An Assembly Consists of one or more files( Dlls, exes, Html files etc) , which represents a group of resources ,Type Definitions and Implementation of those Types.
An Assembly may also contain references to other assemblies.
Querry??  What is Versioning in .NET ?
Each assembly has a four-part version number as a part of its identity. This version number is essential to distinguish different versions of an assembly for the purposes of side-by-side.
The 4 part number will be in the following format.
MajorVersion.MinorVersion.BuildNumber.Revision
Assemblies of either of first two parts different are viewed as ‘Incompatible’.
If First two parts are same , but third is different , the assemblies are referred as ‘may be compatible’.
If only fourth part is different , assemblies are declared as ‘Compatible’
NB:-This version policy can be specified via ‘The Application Configuration File’

Querry??  What is Manifest?
Manifest is the set of Metadata that describes the contents of the assembly and the Metadata also describes the dependencies and Version Information associated with an assembly.
Querry??  What are different types of Assemblies?
There are Two Types of Assemblies. They are Private Assembly and Shared Assembly.
Private Assembly is used by a single application and is stored in Application Directory or a subdirectory beneath.
Shared Assembly is used by Multiple Applications and is Stored in Global Assembly Cache(GAC).Runtime enforces Versioning Constraints on Shared Assemblies only and not on Private Assemblies.

Querry??  What is GAC?
Global Assembly Cache is a repository of assemblies maintained by .NET runtime.
Querry??   How Assebly Dll or exe is checked?
Using ILDASM.EXE Utility.
Querry?? What is reflection?
All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System. Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

Querry?? What is .NET Class Library?

.NET Class Library is a collection of reusable types that are tightly integrate with the Common Language Runtime, from which your own Managed Code can derive functionality.


Querry??  Manifest:
It contains assembly name, version number, referenced assemblies, strong name etc
It contains detailed description of the assembly contents. A manifest contains metadata describing the name, resources, types, and version of the assembly as well as dependencies upon other assemblies. The manifest makes an assembly self-describing, easier to deploy, and not bound to a particular system because of storing data in the windows registry.

Manifest mainly contains four parts:

1. Identity: Name of the assembly. That means what’s used to uniquely identify this particular assembly.
2. Strong name: It is a public key which is generated by author of the assembly to shared assembly to identify it uniquely.
3. Version no: This describes the no of the version.
How can a version no. is given to assembly? (Major.Minor.Build.Revision) Eg: 1.6.12.20
4. Referenced assemblies: This is the reference where the information is recorded about the assemblies.

?Types of assemblies:
1. Application _Private assembly: This is being generated for a particular application. We can use this assembly only in that particular application. We can’t share it to other applications
2. Shared assembly: It’ll reside in Global Assembly Cache (GAC), we can use that in any other application.
Path to view shared assemblies: c: windows\ assembly

• ILDASM.EXE ? Used to view the details of a particular assembly.
• SN.EXE? Nothing but strong name indication
• GACUTIL.EXE? By using this command we can install/uninstall the assembly from GAC (Global Assembly Cache)

The procedure to Add The Assembly to the cache:

1) Go to command prompt
2) C:\program files\Microsoft visual studio 8\Uc>cd
3) C:\>sn(space) –k(space).snk?press enter Eg: apl.snk
4) Goto my documents? projects?open the project which u desired?click on solution explorer’s second option (show all files)?click on myproject?select assembly info.vb
5) Create an assemblykey file as Eg: (“apl.snk”) create build.
6) Goto command prompt
7) C:\>gacutil.exe –I (give the path where our appln is resided)
8) Eg: c:\.gasutil.exe –I D:\>winapp\winapp\bin\debug\winapp.exe.


Querry?? What is Application Domain?
Application Domain is a Construct in the CLR that is the unit of isolation for an application.
The Isolation Guarantees the following:
a) An Application Can be Independently stopped.
b) An Application cannot directly access code or resources in another application.
c) A fault in an application cannot affect other applications.
Querry?? What platforms do the .NET Framework run on?
The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.

Querry?? What is garbage Collection?
Garbage Collection is a system by which Common Language Runtime takes responsibility for managing the lifetime of Objects and heap memory that they occupy.

Garbage collection is an algorithm. It works by periodically running through a list of all the objects that are currently being referenced by an application. All objects that it doesn’t find during this search are ready to be destroyed and the memory reclaimed.

The Implication of this algorithm is that the runtime doesn’t get notified immediately when the final reference on an object goes away-it only finds out during the next sweep of the heap.

For this Microsoft Recommends Dispose() method and Finalize() methods, to get freed object resources.
NB:- System.GC class provides Collect method that uses to collect all un referenced objects immediately.

The syntax implementing the Dispose method of the IDisposable interface and overriding the Finalize method of the Object class is shown with this table:
IL C++/CLI C# VB
Dispose ~ClassName Dispose Dispose
Finalize !ClassName ~ClassName Finalize

Visual Basic does not hide Dispose and Finalize. The automatically created code (with Visual Studio 2005) also includes the Dispose(bool) pattern.
class Resource : IDisposable
{
private bool disposed = false;
~Resource()
{
Dispose(false);
}
protected void Dispose(bool disposing)
{
if (disposing)
{
// dispose managed resources
}
// dispose unmanaged resources
disposed = true;
}
#region IDisposable Members
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion

13 comments:

Thanks For your Comments Please Continue with your precious Time and greate Knowladge will be benificial for learner like me thanks a lot...........