<<

Introduction to .NET Framework

Prepared by: Rajani Khushal K. Software Framework

• In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by code, thus providing application specific software. • It is a collection of software libraries providing a defined application programming interface (API). Software Framework

• Frameworks contain key distinguishing features that separate them from normal libraries: – inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework. – default behaviour - A framework has a default behaviour. This default behaviour must actually be some useful behaviour and not a series of no-ops. Software Framework

• Frameworks contain key distinguishing features that separate them from normal libraries: – extensibility - A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.

– non-modifiable framework code - The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code What Is .NET • .Net is a new framework for developing web-based and windows-based applications within the environment. • The framework offers a fundamental shift in Microsoft strategy: – It moves application development from client- centric to -centric. What is .NET?

• The .NET Framework (pronounced dot net) is a software framework that runs primarily on . • It includes a large and supports several programming languages which allows language interoperability (each language can use code written in other languages). .NET – What Is It?

.NET Application

.NET Framework

Operating System + Hardware Framework, Languages, And Tools

VB VC++ VC# JScript …

Common Language Specification Visual Studio.NETVisual

Common

NET

Windows ADO .NET ASP .NET Console Forms

Base Class Library

Common Language Runtime .NET Framework 3.5 Components of .NET Framework 3.5

(CLR) • (CTS) and Common Language Specification (CLS) • .NET Framework Class Library • Assemblies and Metadata • • ASP .NET and ASP .NET • ActiveX Data Object for .NET (ADO .NET) Components of .NET Framework 3.5

• Windows Presentation Foundation (WPF) • Windows Communication Foundation (WCF) • Windows WorkFlow Foundation (WF) • Windows CardSpace (WCS) • Language Integrated Query (LINQ) Common Language Runtime (CLR)

• It provides functionalities such as: – Memory Management – Exception Handling – Debugging – Security – Thread Execution – Code Execution – Code Safety – Verification – Compilation Common Language Runtime (CLR)

• In other words CLR manages the execution of .NET Code • The code that is executed by CLR is known as Managed code • The code that cannot be directly executed by the CLR is known as Unmanaged Code Working of CLR

• The CLR facilities the interoperability between different .NET languages such as #, VB or Visual C++ by providing a common environment for the execution of code. • When we run a .NET application, the language compiler first complies the source code into an intermediate code called Microsoft Intermediate Language (MSIL) code. Working of CLR

• The MSIL code is then used by the Just in Time Compiler to convert the MSIL code into the native machine code, which is the final executable code. Working of CLR

VB Source Code Complier

Native C# JIT C# Source Code Machine Complier MSIL Code Complier Code

Other .NET Language Other Source Code .NET language Complier Common Type System (CTS)

• CTS is the component of .NET framework which provides support for multiple languages • It contains a set of types and operations, which are found in most of the programming languages. • CTS provides a base set of data types for all the languages supported by .NET framework • Each languages uses aliases for the base types provided by CTS. Common Type System (CTS)

• Two CTS compliant languages do not require type conversion. • For examples: – CTS uses the data type System.Int32 to represent a 4 byte integer value; in Visual C# uses the alias int for the same. Common Language Specification (CLS)

• CLS is a set of basic rules, which enables interoperability between two .NET compliant languages. • The rules defined in CLS serves as guidelines for the third party compiler, designers and library builders. • CLS is a subset of CTS. • Thus the languages supported by CLS can use each other’s class libraries just like their own .NET Framework Class Library

• It is a huge library made up of a hierarchy of namespaces. • Each namespace contains classes, structures, interfaces, enumerations, and delegates. • The namespaces are logically defined by their functionality. • For examples: – System.Data contains the functionality for accessing database .NET Framework Class Library

• The classes, interfaces, structures and enumerations are collectively referred to as types. • The System namespace is the root for some of the commonly used types in .NET Framework • Some important of classes in System namespace are Console, Math, Object, String, Array, Enum and Delegate. Assemblies and Metadata

• In .NET every application is compiled into assembly, which forms the unit of deployment, versioning, code reuse and security of the application. • An assembly refers to a file. • The PE file can either be a dynamic linked library or an executable file which contains the MSIL code of the compiled application. Assemblies and Metadata

• In addition to MSIL, an assembly contains the files and resources necessary for the application, assembly metadata, and type metadata. • The assembly metadata is the metadata about the assembly itself and its components. • The type metadata is the metadata about the types required for the assembly. Assemblies and Metadata

• A metadata describes a program that is in the form of binary information stored in an assembly. JIT Compiler

• When any .NET application compile , It is not converted into machine code but It is converted into MSIL. This code is machine independent so CLR provide Just In Time compilation Technology to convert the MSIL code into platform code (Native machine code) so that it can be executed. Types of JIT

• Pre-JIT COMPILER : Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.

• Econo-JIT COMPILER: Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required. Types of JIT

• Normal-JIT COMPILER: Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution. Garbage Collection

• Memory Management is one of the housekeeping duty that takes a lot of programming time in Developing application. • We doesn’t like spent a time for programming related to memory. • So .NET provides a environment with garbage collection system. Garbage Collection

• Garbage collection runs when application needs free memory. • There is no exact time of execution of garbage collection system. • When application required more memory and memory allocator reports that there is no free memory than garbage collection is called. Garbage Collection

• It starts by assuming everything should be deleted from the memory. • First it creates the graph of used memory by application , when it has a complete graph of memory used by application then it copies this data and free up the whole memory. • Garbage Collector also free up the memory for unused object at regular interval. Note

• When the compilation of takes place in a PE file, the metadata is inserted into one part of the file, while the code is converted into IL and inserted into the other part of the file. • The metadata describes every type and member. • At run time, the CLR loads the metadata into the memory and find information about the code’s classes, members and so. Contents of Metadata

• A metadata contains information about the code in a language neutral manners • The meta includes the following information: – Assembly information such as its identity which can be name, version, culture and so on. – Information about types, such as name, visibility, base class, interface and members. – Attribute information which modifies the types and members of the class. Windows Forms

• Windows Forms applications allows us to develop window based desktop applications • The basic entity of a Windows Forms Applications is a form, which is an rectangular area on which we can place various control. • In this we could add controls to the window form and develop response to the user actions. ASP .NET and ASP .NET Ajax

• ASP .NET is a Web development model, which is used to develop interactive, data driven web applications over the internet • We can add controls and respective events to various controls on the forms • AJAX, formerly code named as Atlas, is an extension of ASP .NET for developing and implementing AJAX functionality. ASP .NET and ASP .NET Ajax

• ASP .NET Ajax includes both client side and server side components that allows developers to create web applications such that the applications do not require complete reload of the page. • It enables us to send only the modified portions of a web pages to the web server by making asynchronous calls to the web server. ADO .NET

• It is the technology that is used for working with data and databases of all types. • It provides access to various data sources such as MS SQL Server, and data sources exposed through OLE DB and XML. • We use ADO .NET to retrieve, manipulate and update data. Windows Presentation Foundation (WPF) • WPF provides developers a single and integrated platform to incorporate 2-D and 3- D graphics, videos and documents without the need for any separate . • WPF supports eXtensible Application Markup Language (XAML), which is a markup language by Microsoft. Windows Communication Foundation (WCF) • To enable various applications communicate with each other in such a way that applications uses the features and functionalities extended by another applications WCF came into existence. • WCF enables us to build powerful and interoperable service oriented applications with Web Services and Web Services Clients. Windows Workflow Foundation (WF)

• It is a technology introduced by Microsoft in .NET framework 3.0 and 3.5. • It provides a programming model for building workflow based applications on Windows. • It includes various components, such as activities, workflow runtime, workflow designer and a rules engine. • WF facilities the separation between the business process code and the actual implementation code Windows Cardspace

• It is client software provided by Microsoft • It makes the process of securing resources easier and also makes sharing personal information on the internet more secure. • It helps develop web sites and software that are less prone to identity attacks. Windows Cardspace

• WCS also solves the problems of traditional online security mechanisms by reducing dependences on username and • It uses a separate desktop and cryptographically strong authentication to ensure online transactions Language Integrated Query (LINQ)

• It is a component of .NET Framework 3.5 • It adds native data querying capabilities to .NET languages using the syntax similar to SQL • This implies that with LINQ, we can write statements similar to SQL statements in a .NET language. • Also we can query SQL server database, datasets, objects in a collection and XML documents. Main Features of Visual Studio 2008

• Support for multi targeting • Support for ASP .NET Ajax and Jscript Intellisense • Support for LINQ • Improved Deployment of .NET applications. Types of Visual Studio 2008 Applications • Visual Studio provides several project templates to develop different types of .NET applications. • By default the project templates includes the essential files and assemblies in the applications thus it becomes easy and convenient. Types of Visual Studio 2008 Applications • Types of Applications: – Console Applications – Windows Applications Console Applications

• It refer to those .NET applications that do not have graphical except for a command line console. • Users of a console applications can interact with the applications only through the command line console. • Thus data is displayed and read through command line only. Windows Applications

• Windows based desktop applications are those applications that are installed and run on user’s computer. • There are mainly two types of Windows Applications: – Windows Forms – Windows Presentation Foundation (WPF) • Both these applications have a rich GUI that facilitates easy and quick user interactivity.