Introducing Microsoft .NET

Introduction to Microsoft .NET
Microsoft .NET Framework Process
Pictorial Representation
Common Language Runtime
Microsoft .NET Class Libraries
About Namespaces
Common Language Specification
Related Links

 

Introduction to Microsoft .NET

Ever since Microsoft released Windows 95 Operating System, there has been a high demand for more and more reliable products from customers. Taking this into consideration, the company introduced a plethora of new products within a span of 6 years. The products include range of Operating Systems to Office based applications, Programming tools and environments etc. In the mean time, Sun Microsystems Java language, Solaris Operating System became much popular among developers. Hence, many of the developers and companies began shifting their platforms to these powerful ranges of products. One more reason for this shift attributed to the strong stability of Sun’s products. In these circumstances, developers at Microsoft began to think of bringing a set of technologies, which caters to all needs. In early 2000, the company released its first beta product of its new .NET initiative. The product evoked added response and in 2001 they released Beta 2 of the same and the final release of the whole range of stuffs culminated with VSLive conference in early 2002. In this first session, you will be introduced with this new Microsoft .NET technology.

Microsoft .NET is one of the latest and new technologies introduced by Microsoft 
Corporation. Nowadays we use to connect to the Internet using a computer 
and remote computer responses via a web page and a collection of web pages 
are called as Web Sites. The concept in .NET is that these websites can 
integrate with other sites and services using standard protocols like HTTP.

Microsoft .NET Platform comprises of four core components such as:

·        .NET building block services such as file storage, calendar under the banner called Passport .NET.

·        .NET device software’s that will run on latest Internet devices like mobile phones, pagers and so on

·        .NET user experience such as integrating this technology to user created
 documents (like XML). For example, if you write a code snippet via 
 XML using a  .NET Language like C#, it will automatically create relevant XML documents.

·        .NET infrastructure which includes:

1.      .NET Framework, which comprises of Common Language Runtime (CLR) and .NET Framework class libraries. You will learn more about CLR in chapter 3.

2.      Microsoft Visual Studio.NET such as Visual Basic .NET,

      Visual C# .NET, Visual C++ .NET with managed extensions,

      Visual FoxPro etc.

3.      Highly reliable servers called .NET Enterprise Servers and Microsoft

Windows NET.


We can build robust, scalable, distributed applications with the help of .NET
and the part that helps us to develop these applications is called the .NET Framework.  
The .NET Framework contains Common Language Runtime (CLR) and the 
.NET Framework class libraries also called as base class libraries.

All the .NET languages like C-Sharp, Visual Basic .NET, Visual C++ .NET have
the .NET Framework class libraries built into them. The .NET class libraries also supports File Input and Output, database operations, XML (Extensible Markup Language) and SOAP (Simple Object Access Protocol). For example, you can develop XML pages by using C-Sharp language.
 
When someone talks about .NET development, then you should understand that they are talking about .NET Framework. It includes a runtime environment and a set of class libraries, which is being used by a new language called C-Sharp, abbreviated as C#. C# is more or less similar to C++ and Java and all other .NET languages. If you learn one language, then it’s easy to grasp others. Simply speaking, C-Sharp is a new language for developing custom solutions for Microsoft's .NET platform. 
 
The runtime which we discussed just now is also used by Visual Studio .NET. Visual Studio .NET provides us with a visual environment to design and develop .NET applications. Every language in Visual Studio .NET uses this runtime to execute its applications. Moreover, these languages compile its source code into an Intermediate Language (IL) upon compilation. We will discuss more about Intermediate Language in another article. Hence, you can use a module written using C-Sharp in a Visual Basic application. For example, you can design a user interface with Visual Basic .NET and write a DLL function using C-Sharp.

 

.NET Framework Process in detail

Every Programming Language has got its own process for compiling and executing its source codes. In this article, we will look into these aspects of C#. You have to be thorough with this process, with out which it’s not possible to move ahead to other sessions.

The whole step is elaborated below and Figure 1 explains this process in a diagrammatic manner:

·        The programmer writes the source code using C# language conventions.

·        The source code is then compiled using a C# Compiler (csc.exe).

·        The compiler then converts the source code into an Intermediate Language, much like byte codes in Java. The Intermediate Language can be either an executable (exe) or a Dynamic Link Library (DLL). Since the Intermediate Language is generated by the C# compiler, it is called as Managed Code. Managed Code can be executed only on a .NET aware Platform. 

·        The compiled file unit is then executed using the C# Interpreter. Upon execution, the code is checked for type safety. Moreover, the Just In Time (JIT) compiler compiles the unit into Managed Native Code and finally Common Language Runtime (CLR) produces the final output.

The final unit can be executed on any system having Common Language Runtime installed on it. The C# Compiler and Interpreter will be installed at the time of installing the .NET Framework Software Development Kit (SDK). The SDK can be downloaded from Microsoft’s website or can be obtained in CD. You can find a list of related links at the end of this article.

The above-mentioned steps are applicable to all .NET languages. For instance, Visual Basic .NET also follows the same steps for its source codes. It is due to this reason, .NET technology have become much popular while in beta stage itself.

 

Pictorial Representation

The above-mentioned steps are outlined in the figure given below for better understanding of the topic

.NET Framework Process

Common Language Runtime

Common Language Runtime also called as CLR provides a universal execution engine for developer’s code. It generates Simple Object Access Protocol (SOAP) when it makes remote procedure calls. SOAP is a protocol used to access .NET Web-Services. CLR is independent and is provided as part of the .NET Framework. The main features of CLR are as follows:

·        Managed Code 

·        Automatic Application Installation

·        Effective Memory Management

·        Automatic Garbage Collection

·        Very high level of Security while executing the programs.

 

.NET Framework Class Libraries

The .NET Framework class libraries work with any language under the Common Language Runtime environment. These libraries will be automatically installed at the time of running the .NET SDK Setup program. Therefore, if you are familiar with one .NET language then you can easily migrate to other .NET languages without spending much time to learn new syntaxes and conventions.

You can develop three kinds of tasks using these class libraries. They are Windows Forms Programming (popularly called WinForms), Web Forms Programming and Web Service Programming. Windows Forms are used to develop Windows based Graphical User Interface applications. They are like Standard Exe applications in Visual Basic 6.0. All .NET languages use this concept of WinForms for developing Windows based applications. Web Forms are used to design and develop Web based applications. WebForms are used to create GUI’s for ASP.NET applications. They can handle event handling, Validate Fields and can perform whole lot of functions. On the other hand, Web Services are components, which have no user-interfaces and are consumed by Web applications. Web Services combine the power of HTTP and XML to generate SOAP, which is termed as a lightweight XML based protocol. SOAP stands for Simple Object Access Protocol. A complete discussion on Web Services is beyond the scope of this article.

The Figure given below shows an outline of the .NET Framework hierarchy.

.NET Framework Hierarchy

 

About Namespaces

At the top level of the hierarchy, is the new concept of Namespaces. Namespaces are group of classes and from these classes there will be Methods. Basically, namespaces are containers for all classes and are classified into several categories, based on its functionalities. For example, if you need to add records to a database, you need to call several classes, methods and properties of a namespace called System.Data. This is similar to Packages in Java, where we will use Java.sql.* statement. Moreover, all C# programs should call System namespace. This is the root of all other namespaces in .NET Framework.

Simply putting a statement like System.Data in your source code will not suffice. You have to apply it by following certain conventions. All namespaces should have to be called in your programs by applying the keyword using. For example, to call System namespace you have to use a statement as shown below:

using System;

You should end C# statements using a semicolon. Keep in mind that you cannot call Classes along with the using keyword. The using directive applies only to namespaces.  Hence the following code will result in compilation error:

using System.Console;

Console is one of the classes in the System namespace. We will use its WriteLine() method for outputting information on to the console. However, you can create an alias as shown in the following code fragment: 

using mysys = System.Console;

Then you have to apply the alias in your program as shown below:

mysys.WriteLine("Hello C#");

Common Language Specification (CLS)

It’s a set of rules that a language compiler must adhere to in order to create .NET applications that run in the CLR. If you are going to create a compiler for .NET, you have to adhere to the rules enumerated in the common language specification and this enables us to create a club of CLS compliant languages.

Each such compiler will have the following features:

·        Complete access to .NET Framework hierarchy

·        High level of interoperability with other compliant languages like Visual Basic .NET, Visual C# .NET and etc

For example, a Visual Basic class can inherit from a C# Class and vice versa. You should note that the syntaxes and other programming structures differ little bit from each of these languages. The only difference is that a developer well versed with a language such as C-Sharp can easily program in Visual Basic .NET or Visual C++ .NET without investing a lot or spending too long to learn a new language. Isn’t it exiting?

 

Related Links

·        Microsoft .NET Framework SDK

      http://msdn.microsoft.com/msdn-files/027/000/976/Search.asp

·        Download Link

      http://download.microsoft.com/download/.netframesdk
/SDK/1.0/W98NT42KMeXP/EN-US/setup.exe

·        SDK on CD-ROM

                  http://microsoft.order-2.com/developertools

·        Visual Studio Home Page

      http://msdn.microsoft.com/vstudio 

·        More about Microsoft products

http://shop.microsoft.com     

 

About the Author 

Anand Narayanaswamy is the Founder/Editor of Learnxpress.com. He is a Microsoft Most Valuable Professional (MVP), Author and Trainer. Anand can be reached via the contact desk of this site.