2.1 The .NET Strategy
We briefly discussed in the previous chapter how C# was created as a language for developing systems for the .NET platform. As pointed out, Microsoft wanted to make the World Wide Web(WWW) more vibrant by enabling individual devices, computers and web services to work together intelligently to provide richer solutions to user. By the intelligent integration of web sites on the internet, users can create a wide variety of value-based applications such as unified banking services, electronic bill payment, stock trading, insurance services and comprehensive supply chain management. Microsoft calls this ‘web services’ and the software strategy for implementing and delivering these services is ‘.NET’.
.NET is a software framework that includes everything required for developing software for web services. It integrates pre-sensation technologies, component tech-nologies and data technologies on a single platform so as to enable users to develop Internet applications as easily as they do on desktop systems. Microsoft took many of the best ideas in the industry, added their own creativity and innovations and produced a coherent systems solution popularly known as Microsoft .NET.
Microsoft .NET platform includes the following components that would help develop a new generation of smart Internet Services:
- .NET infrastructure and tools
- User experience
- .NET Building block
- .NET device software
Microsoft .NET products and services consist of the following:
- Windows .NET
- Visual Studio.NET
- Personal Subscription Services
- bCentral for.NET
Third-party .NET services will provide opportunities to a vast range of developers and users to produces corporate and vertical services using.NET platform.
2.2 The .NET Framework
The .NET Framework is one of the tools provided by the .NET infrastructure and tools component of the .NET.
The .NET platform provides a new environment for creating and running robust, scalable and distributed applications over the Web.
The .NET Framework provides an environment for building, deploying and running web services and other applications. It consists of three distinct technologies as:-
- COMMON LANGUAGE RUNTIME(CLR)
- FRAMEWORK BASE CLASSES
- USER AND PROGRAM INTERFACES(ASP.NET AND WINFORMS)
The CLR is the core of the .NET framework and is responsible for loading and running C# programs. Base classes provide basic data types, collection classes and other general classes for use by C# and other .NET languages. The top layer contains a set of classes for developing web services and to deal with the user interface.
2.3 The Common Language Runtime
The common language runtime, popularly known as CLR is the heart and soul of the .NET framework. As the name suggest, CLR is a runtime environment in which programs written in C# and other .NET languages are executed it also supports cross-language interoperability.
Summary of the major components of the CLR.
The CLR provides a number of services that include:
- Loading and execution of programs
- Memory isolation for applications
- Verification of type safety
- Compilation of IL into native executable code
- Providing metadata
- Memory management(automatic garbage collection)
- Enforcement of security
- Interoperability with other systems
- Managing exceptions and errors
2.3.1 Common type System (CTS)
The .NET framework provides multiple language support using the feature known as common type system that is built into the CLR. The CTS supports a variety of types and operations found in most programming languages and operations found in most programming languages and therefore calling one language from another does not require type conversions. Although C# is specially designed for the .NET we can build .NET programs in a number of other languages including C++ and Visual Basic.
2.3.2 Common Language Specification (CLS)
The Common Language Specification defines a set of rules that enables interoperability on the .NET platform. These rules serve as a guide to third party compiler designers and library builders. The CLS is a subset of CTS and therefore the languages supporting the CLS can use each other’s class libraries as if they are their own. Application program interfaces (APIs) that are designed following the rules of CLS can easily be used by all the .NET languages.
2.3.3 Microsoft Intermediate Language (MSIL)
MSIL, or simply IL, is an instruction set into which all the .NET programs are compiled. It is akin to assembly language and contains instructions for loading, storing, initializing and calling methods. When we compile a C# program or any program written in a CLS compliant language, the source code is compiled into MSIL.
2.3.4 Managed Code
As we know, the CLR is responsible for managing the execution of code compiled for the .NET platform. The code that satisfies the CLR at runtime in order to execute is referred to as managed code. Compilers that are compatible to the .NET platform generate managed code. For Example, the C# compiler generates managed code. The managed code generated by C# (and other compilers capable of generating managed code) is IL code. The IL code is then converted to native machine code by the JIT compilers.
2.4 Frameworks base Classes
.NET supplies a library of base classes that we can use to implement applications quickly. We can use them by simply instantiating them and invoking their methods or by inheriting them through derived classes, thus extending their functionality.
Much of the functionality in the base framework classes resides in the vast namespace called system.
We can use the base class in the system namespace for many different tasks including:
- Input/output Operations
- String handling
- Managing arrays, list, maps, etc
- Accessing files and file systems
- Accessing the registry
- Windows Messages
- Database Management
- Evolution of mathematical functions
- Managing errors and exceptions
- Connection to the internet
- And many more
2.5 User And Program Interfaces
The .NET framework provides the following tools for managing user and application interfaces:
- Windows Forms
- Console Applications
- Web forms
- Web Services
These tools enable user to develop user friendly desktop based as well as web based applications using a wide variety of languages on the .NET platform.
2.6 Visual Studio.NET
Visual Studio .NET (vs.NET) supports an integrated Development Environment (IDE) with a rich set of features and productivity tools. These features and tools allow developers to build web applications faster and easier. Using web services and XML regardless of the language chosen for development, there is now one environment to learn, configure and use. We need not have to switch back and forth between environments to build, debug and deploy our code. Vs.NET provides a tool that extends support to the development lifecycle.
2.7 .NET Languages
The .NET framework is language neutral. Currently, we can use a number of languages for developing .NET applications. They include:
2.7.1 Native to .NET
- C# (Specially created for .NET)
- Visual Basic
2.8.2 Third Party Languages
All .NET Languages are not created equal. Some can use the components of other languages, some can use the classes produced in other languages to create objects, and some languages can extend the classes of other languages using the inheritance features of .NET
2.8 Benefits of The .NET Approach
Microsoft has advanced the .NET strategy in order to provide a number of benefits to developers and users. Some of the major benefits envisaged are:
- Simple and faster systems development
- Rich object model
- Enhanced built in functionality]’
- Many different ways to communicate with the outside world
- Integration of different languages into one platform
- Easy deployment and execution
- Wide range of scalability
- Interoperability with existing applications simple and easy to build sophisticated development tools
- Fewer bugs
- Potentially better performance
2.9 C# and the .NET
C# is a new programming language introduced with .NET. It is a concise, elegant .NET language. In many respects it is a version of the .NET object model. With C#, Developers can quickly implement applications and components using the built in capabilities of the .NET Framework. Since the C# code is managed by the CLR (of the .NET framework) it becomes leaner and safer than C++.
The CLR extends a number of benefits to C# when it is implemented on the .NET platform. These include:
- Interoperability with other languages
- Enhanced security
- Versioning support
- Debugging support
- Automatic garbage collection
- XML support for web based applications.