You are on page 1of 12

Module1-Part1

Introduction to .Net Framework

1.1 What Is the Microsoft .NET Framework.


Microsoft .NET Framework is a complex technology that provides the infrastructure for building, running, and managing next
generation applications which can be fall into various categories like console(system programming ex-drivers developing),
windows(graphic interface), web applications(over the network), code libraries, windows & web services, user component & control
designing.

 NET is a software framework/infrastructure developed by Microsoft used to develop, run, and deploy the applications like
console applications, web services and web applications.
 In a layered representation, the .NET Framework is a layer positioned between the Microsoft Windows operating system and
your applications.
 .NET is a platform but also is defined as a Technology because it is composed of several parts such as libraries, executable
tools, and relationships and integrates with the operating system.

Microsoft Visual Studio 2015 relies on the new version of the .NET Framework 4.5.2. Visual Basic 2015, C# 4.5, and F# 2015 are .NET
languages that rely on and can build applications for the .NET Framework 4.5. The new version of this technology introduces important
various new features that impose lots of enhancements and came up with the new era of programming tools and environment.

1.1.1 New Features introduced is the .NET Framework

It’s no secret among developers that there is no better development environment than Microsoft Visual Studio. It offers the most
complete set of tools to create powerful windows, web or any other application and can be done in almost any common language.
Visual Studio is available in a version that fits every developer’s needs.

Newly Added Features


 Custom Windows Layouts  Visual Studio Emulator for Android
 Better Code Editor  Unit tests
 Shared Project – “All the Things!”  Code Map
 Debug Lambdas  Diagnostics Tools

1.1.2 Where is the .NET Framework

 When you install Microsoft Visual Studio, the setup process installs the .NET Framework. .NET is installed to a folder named
%windir%\Microsoft.NET\Framework\....
 If you open this folder with Windows Explorer, you see a lot of subfolders, libraries, and executable tools. Most of the DLL
libraries constitute the Base Class Library, whereas most of the executable tools are invoked by Visual Studio to perform
different kinds of tasks, even if they can also be invoked from the command line.
 Now you need to notice the presence of a file named Vbc.exe, which is the Visual Basic Compiler and a command line
tool.
 In most cases you do not need to manually invoke the Visual Basic compiler, because you will build your Visual Basic
applications writing code inside Visual Studio, and the IDE invokes the compiler for you.
 This means that the Visual Basic compiler is also provided free with .NET, and this is the philosophy that characterizes the
.NET development since the first version was released in 2002.
1.2 What Is Visual Basic .NET?
Visual Basic .NET (VB.NET) is an object-oriented computer programming language implemented on the .NET Framework. Although it
is an evolution of classic Visual Basic language, it is not backwards-compatible with VB6, and any code written in the old version does
not compile under VB.NET.

Like all other .NET languages, VB.NET has complete support for object-oriented concepts. Everything in VB.NET is an object, including
all of the primitive types (Short, Integer, Long, String, Boolean, etc.) and user-defined types, events, and even assemblies. All objects
inherit from the base class Object.

VB.NET is implemented by Microsoft's .NET framework. Therefore, it has full access to all the libraries in the .Net Framework. It's
also possible to run VB.NET programs on Mono, the open-source alternative to .NET, not only under Windows, but even Linux or
Mac OSX.

The following reasons make VB.Net a widely used professional language:

 Modern, general purpose.  Structured language.


 Object oriented.  It produces efficient programs.
 Component oriented.  It can be compiled on a variety of computer platforms.
 Easy to learn.  Part of .Net Framework.

1.2.1 Strong Programming Features VB.Net


VB.Net has numerous strong programming features that make it endearing to multitude of programmers worldwide. Let us mention
some of these features:

 Boolean Conditions  Delegates and Events Management


 Automatic Garbage Collection  Easy-to-use Generics
 Standard Library  Indexers
 Assembly Versioning  Conditional Compilation(option explicit)
 Properties and Events  Simple Multithreading(code and resourse optimization)

1.2.2 VB or VB.Net?
VB.NET is part of a brand new platform, based on the .NET Framework. All languages in .NET are based on this new platform, which
allows many great new capabilities for a VB developer. Because the .NET Framework is fully object-oriented, .NET languages also
must support OO features.

 VB.NET is fully object-oriented where as Visual Basic was object based(does not support polymorphism and inheritance).
 It also introduces another level of complexity along with this new power.
 VB. NET came up with advanced error handling and debuggers.
 Various application settings stored in XML config files which also makes things a bit simpler to produce and deploy..
 An incredible IDE.
 Fully support to service oriented architecture.
 Cross-language inheritance
 Provide solution for situations like DLL Hell. "DLL Hell" refers to the set of problems caused when multiple applications
attempt to share a common component like a dynamic link library (DLL) or a Component Object Model (COM) class. This
problem was solved by using the concept named as ‘Versioning’.

1.3 The .Net Framework & Its Architecture


.NET provides an object oriented environment. It ensures safe execution of the code by performing required runtime validations. For
example, it is never possible to access an element of an array outside the boundary. Similarly, it is not possible to a program to write
into another programs area, etc. The runtime validations performed by .NET makes the entire environment robust.

Following are some of the components of the .Net Framework:

 Common Language Runtime (CLR)


 The .Net Framework Class Library
 Common Type System
 Common Language Specification
 Metadata and Assemblies
 Windows Forms
 ASP.Net and ASP.Net AJAX
 ADO.Net
 Windows Workflow Foundation (WF)(foundation servers)
 Windows Presentation Foundation
 Windows Communication Foundation (WCF)
 LINQ(client site programming for database for faster processing)

1) The first level of the .Net Framework representation is the operating


system; the .NET layer is located between the system and applications.
2) The second level is the Common Language Runtime (CLR), which
provides the part of the .NET Framework doing the most work.
3) The next level is the Base Class Library (BCL), which provides all .NET
objects that can be used both in your code and by Visual Basic when
creating applications.
Advantages of .Net Framework:

1) It provides a consistent object oriented programming infrastructure.


2) Software Deployment is minimized and also versioning problems.
3) Consistency in developing window and web based applications.
4) Promotes safe execution of code.
5) It significantly decreases the quantity of code necessary in large web
applications which are developed in .Net framework.
6) Web applications developed in ASP.Net are secure as Windows
confirmation and configuration can be attained for every application.
7) This development provides WYSIWYG (What You See Is What You
Get).
8) It provides server controls and blueprints with capability of drag and
drop and involuntary operation.
9) All .NET source code is compiled into an intermediate language
also known as IL and then IL gets converted to machine code.
10)Common Type System of the framework defines how types are
declared, used and managed during runtime. It also supports cross
language integration or interoperability.
11)The .NET Framework consists primarily of a gigantic library of code.
12)Provide Type Safety
13)Integrated Development Environment.
14)Auto Memory & Garbage Management.

1.3.1 Components of .Net Architecture

1) Operating System

At the base of the diagram is the operating system, which technically


can be any platform but typically is Microsoft Windows 2000 or
greater, accessed through the Win32 API (Application
Programming Interface) to provide the interaction with the hardware
resources and various services of operating system through system
calls.

2) Common Language Runtime (CLR)

The Common Language Runtime (CLR) is the environment where all


programs in .NET are run. It provides various services, like memory
management and thread management. Programs that run in the
CLR need not manage memory, as it is completely taken care of by
the CLR.
For example, when a program needs a block of memory, CLR
provides the block and releases the block when program is done with
the block.

All programs targeted to .NET are converted to MSIL (Microsoft


Intermediate Language). MSIL is the output of language compilers in
.NET. MSIL is then converted to native code by JIT (Just-in Time
Compiler) of the CLR and then native code is run by CLR. The CLR
is the execution engine for .NET applications and serves as the
interface between .NET applications and the operating system.

Programmers writing in any of Visual Basic , Visual C++ , or C#


compile their programs into an intermediate form of code called
Common Intermediate Language ( CIL ) in a portable execution (
PE ) file that can then be managed and executed by the Common
Language Runtime.

Note: The code that is run under CLR is called Managed code.
Common Language Runtime is the heart of the .NET framework.
CLR provides a number of services that includes:

 Loading and executing of programs


 Memory management & Garbage Collection
 Verification of type safety
 Code Base & Code Access Security
 Interoperability with other system
 Compilation of IL into native executable code (Just In Time
compilation)
 Managing exception and errors
 Provides debugging, etc.

3) Basic Class Library (BCL)

.NET comes with thousands of classes to perform all important and


not-so-important operations. Its library is completely object oriented,
providing around 7000 classes to perform just about everything.

 BCL enable .NET applications to read and write files, access


databases, process XML, display a graphical user interface,
draw graphics, use Web services, etc.
 The FCL/BCL wraps much of the massive, complex Win32 API
into more simple .NET objects that can be used by C# and other
.NET programming languages.
 The most fascinating part of .NET is the class library; it's common
to all language of .NET. That means the way you access files in
VB.NET will be exactly same in C#, and in fact all other
languages of .NET. You learn library only for once, but use it in
every language as well as common for all types of applications.

4) Common Type System (CTS)

It defines the rules which Common


Language Runtime follows when
declaring, using, and managing types. The
common type system performs the
following functions:
 It enables cross-language
integration, type safety, and high-
performance code execution.
 It provides an object-oriented model for implementation of many
programming languages.
 It defines rules that every language must follow which runs under
.NET framework.
 It ensures that objects written in different .NET Languages
like C#, VB.NET, F# etc. can interact with each other.
 For example, C# has int Data Type and VB.Net has Integer
Data Type. Hence a variable declared as int in C# or Integer in
vb.net, finally after compilation, uses the same structure Int32
from CTS.
 All the structures and classes available in CTS are common for
all .NET Languages and purpose of these is to support language
independence in .NET.

5) Common Language Specification (CLS)

What makes a language to be .Net compliant? Answer is CLS.


CLS stands for Common Language Specification and it is a subset
of CTS. It defines a set of rules and restrictions that every language
must follow which runs under .NET framework.
The languages which follow these set of rules are said to be CLS
Compliant. In simple words, CLS enables cross-language integration.
For example, one rule is that you cannot use multiple inheritance
within .NET Framework. As you know C++ supports multiple
inheritance but; when you will try to use that C++ code within C#, it is
not possible because C# doesn’t supports multiple inheritance.
1.4 Microsoft Intermediate Language (MSIL)
1) Managed Code

 The resource, which is within your application domain is, managed code.
 The resources that are within domain are faster.
 The code, which is developed in .NET framework, is known as managed code. This code is directly executed by
CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.
 Managed code uses CLR which in turns looks after your applications by managing memory, handling security,
allowing cross - language debugging, and so on.

2) Un-Managed Code

 The code, which is developed outside .NET, Framework is known as unmanaged code.
 Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such
as C++ can be used to write such applications, which, for example, access low - level functions of the operating
system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code.
 Unmanaged code is executed with help of wrapper classes which are of two types: CCW (COM callable wrapper)
and RCW (Runtime Callable Wrapper).
3) Native Code

 The code to be executed must be converted into a language that the target operating system understands,
known as native code.
 This conversion is called compiling code, an act that is performed by a compiler.
 Under the .NET Framework, however, this is a two - stage process. With help of MSIL and JIT.

4) Microsoft Intermediate Language (MSIL)

It is language independent code. When you compile code that uses the .NET Framework library, you don't immediately
create operating system - specific native code.

Instead, you compile your code into Microsoft Intermediate Language (MSIL) code. The MSIL code is not specific to any
operating system or to any language.

 MSIL stands for Microsoft Intermediate Language. We can call it as Intermediate Language (IL) or Common
Intermediate Language (CIL).
 During the compile time, the compiler converts the source code into Microsoft Intermediate Language (MSIL).
 MSIL is a CPU-independent set of instructions that can be efficiently converted to the native code.
 During the runtime the (CLR)'s Just In Time (JIT) compiler converts the MSIL code into native code to the
Operating System.
 When a compiler produces MSIL, it also produces Metadata. The MSIL and Metadata are contained in a portable
executable (PE) file.
 The Portable Executable (PE) format is a file format for executables, object code, and DLLs, used in 32-bit and 64-bit
versions of Windows operating systems.
 The PE file format was defined to provide the best way for the Windows Operating System to execute code and also
to store the essential data which is needed to run a program.
 JIT (Just-in-Time) Compiler: JIT compiler, which compiles MSIL into native code that is specific to the OS and
machine architecture being targeted. Only at this point can the OS execute the application. The just - in - time part of
the name reflects the fact that MSIL code is only compiled as, and when, it is needed.

You might also like