Saturday, May 3, 2014

Common Language Runtime

Runtime can be defined as a collection of services that are required to execute a given compiled unit of code.
.NET Runtime provides a single, well defined runtime layer that is shared across all.NET aware languages and is called as Common Language Runtime a.k.a. CLR.

Apart from code execution , CLR provides memory management, thread management, security management, code verification and compilation.

Lets discuss the roles of CLR as given below

Base Class Libraries : This provides class libraries required for an application in .NET world. CLR converts the source code into an intermediate language called Microsoft Intermediate Language (MSIL).

Thread Support: CLR manages the parallel execution of code via threading.

Code Manager : CLR manages the compiled Intermediate Language

Garbage Collector
Garbage Collector handles automatic memory management and it will release memory of unused objects in an application, this provides automatic memory management.

CLSCommon Language Specification (CLS) is defined as a set of rules that describes the minimal and complete set of features a given .NET aware compiler should support. 

CTSCTS defines how various types are declared, used and managed in Common Language Runtime in .NET world

Security Engine: It enforces security permissions at code level security, folder level security, and machine level security using Dot Net Framework setting and tools provided by Dot Net.

Common Language Specification

Common Language Specification (CLS) is defined as a set of rules that describes the minimal and complete set of features a given .NET aware compiler should support. Alternatively we can define it as a sub set of CTS as well. CLS does not apply to the implementation logic. Member definition should conform to the CLS compliance.

Friday, May 2, 2014

Common Type System Overview

In .NET world, Type refers to a generic term used to represent Class, Interface, Enumeration , Delight etc. Whenever we are building any solution around .NET we do interact with these types. So lets define CTS aka Common Type System as "CTS defines how various types are declared, used and managed in Common Language Runtime in .NET world"

  • CTS helps in cross language interaction
  • Provides an Object  oriented model
  • Defines the rules that languages should follow for language interaction.
  • Provides a Base class library that contains primitive data types.
Types can be literally classified as Value Types and Reference Types. Lets define the classification as follows 
Value Types
Value types are data types whose objects are represented by the object's actual value. If an instance of a value type is assigned to a variable, that variable is given a fresh copy of the value.

Reference Types:
Reference types are data types whose objects are represented by a reference (similar to a pointer) to the object's actual value. If a reference type is assigned to a variable, that variable references (points to) the original value. No copy is made.

CTS supports the following categories of types
  • Classes : Classes are Reference types. It defines the operation an object can perform and the data that object contains
  • Structures : Structures refers to Value types. It derives from System.ValueType. Used extensively in low memory requirements.
  • Enumerations : Enumeration are Value types. It derives from System.Enum. It supplies alternate names for the values of an underlying primitive type.
  • Interfaces : Interfaces are contracts which contains declarations of method or properties which an implementing class will do the implementation.
  • Delegates : Delegates are Reference types which is a functional pointer used in event handlers and call back functions in .NET.
CTS type definitions includes the following
  • Any attribute defined on type
  • Type accessibility
  • Type name
  • Types base types
  • Any interface defined by the types
  • Definition for each type members
Type members defines the behavior and state of a types. The following are type members
  • Fields
  • Properties
  • Methods
  • Constructors
  • Events
  • Nested types

Assemblies in CLR

Assemblies are the building blocks of .NET framework applications. An assembly is a collection of similar types and resources that are build to work together and form a logical unit of functionality. Assembly provides the type implementation details for CLR. Assembly forms the fundamental part of deployment,version control,reuse,activation scoping and security permissions.

.NET binaries does not contain platform specific instructions. But instead it contains the paltform agnostic Intermediate Language (IL). It is also known as Microsoft Intermediate Language. All .NET aware compilers produces nearly identical CIL instructions.

JIT (Jitter) compiler compiles the CIL code into meaningful CPU instructions. JIT is flexible enough to execute in different tartgeted environments.

.NET Type Metadata : In addition to CIL instructions, .NET assembly contains metadata. It refers to each and every type, members of each type etc. Metadata is used by numerous aspects of .NET runtime environment.

Assembly Manifest: .NET Assembly also contains metadata that describes the assembly itself. This is called as Manifest. Manifest documents all external assemblies required by the current assembly, version number , copy right information etc.


Thursday, May 1, 2014

.NET Platform

Initially before the .Net Platform were introduced, software development was done using COM (Component Object Model) in Windows operating systems. It was so popular just because of the language independency and reusability across different languages. The demerits of this model was the complexity in infrastructure and deployment.
Later Microsoft introduced the .NET platform in early  2002 and became so popular till date due to its features and flexibility in usage. Lets jote down the advantages of the .NET platform as follows
·         Interoperability
·         Support different languages. .NET family consists of C#,VB,F# etc.
·         Common Language Runtime caters to different .NET languages
·         Common Type System and Common Language Specifications supporting the cross language interactions
·         Base Class libraries shared by all .NET languages

·         Simplified application deployment and maintenance.


We can disucss about the above blocks indvidually in my later blog posts. Now lets see the major enhancements in the history of .NET frameworks and IDE releases.
·         .NET 1.0
o   Introduced with Visual Studio .NET.
o   Intriduced CLR 1.0
o   Support for OOPs in Web application development
o   DLL class libraries
·       . NET 1.1
o   Introduced with Visual Studio .NET 2003
o   Enhancements to ASP.NET and ADO.NET
o   Security enhancements
o   Support for ODBC and databases
·         .NET 2.0
o   Introduced with Visual Studio .NET 2005
o   CLR 2.0
o   Generics and Collections
o   Partial Class
o   Nullable Types
o   Anonymous methods
·         .NET 3.0
o   Introduced with Visual Studio .NET 2005
o   WPF
o   WCF
o   WF
·         .NET 3.5
o   Introduced with Visual Studio .NET 2008
o   Built in Ajax support
o   LINQ
o   Multi targeting Framework support
·         .NET 4.0
o   Introduced with Visual Studi .NET 2010
o   CLR 4.0
o   Managed Extensibility Frameowrk
o   Task parallel library
o   Dynamic Language Runtime
·         .NET 4.5
o   Intriduced with Visual Studio 2012
o   Enhancements to CLR 4.0
o   Async support
o   Support for Windows Store Apps

Keep watching this space for more blogs on C# in the coming days....

Tuesday, November 5, 2013

Unity Framework


Unity is a light weight container used for dependency injection which supports interface, constructor, property and method level injections.
We have the following advantages of using Unity framework


  • Supports object creation
  • Helps to specify dependecies at run time or in configuration
  • It has service location capability which helps to cache the container


We can use Unity in the following scenarios


  • Objects or Classes have dependencies with other objects or classes
  • Dependencies are very complex
  • Manage lifetime of object instances
  • Configure dependencies at run time
  • Cache or persists dependencies


We can download Unity Application block from the following url http://www.microsoft.com/en-us/download/details.aspx?id=19372.

Later in my blog posts I will walk through the implementation of Unity Framework with sample code snippets


Monday, December 31, 2012

The way to MVC4

Now we have ASP.NET MVC4 as the latest version to the MVC family. In the last three years we have seen four releases of MVC. Lets walk through the highlights of each releases as follows.


ASP.NET MVC 1:

• Scot Guthrie introduced ASP.NET MVC in Febriary 2007.

• But official ASP.NET MVC 1.0 was released in 13 March 2009

ASP.NET MVC 2:

ASP.NET MVC 2 was officilly released on March 2010 exactly one year after the prevouos version. Following are the major highlights of the release.

• UI Helpers

• Attribute based model validation both in client and server

• Strongly typed HTML helpers

• Enhancements to Visual studio

• Itroduced HTML.RenderAction

ASP.NET MVC 3:

Just after 10 months , Microsoft has released ASP.NET MVC 3.We have the following enhancements

• The Razor view engine

• Support for .NET 4 Data Annotations

• Enhanced Model validation.

• Enhanced Javascript support, Jquery validation and JSON

• Dependency resolution

• Usage of NuGet module.

ASP.NET MVC 4:

We can consider this release as much stable one compared to the older releases. Microsoft has come up with the following enhancements

• Introduced ASP.NET Web API

• Enhancements to project templates

• jQuery Mobile Project template.
• Display modes

• Bundling and minifications

• Included Json.NET and DotNetOpenAuth libraries.





Installing ASP.NET MVC

Installing ASP.NET MVC Before we dive deep into the ASP.NET MVC, let’s install it our development machine. This is very straight forwa...