dot NET Framework


Published on

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

dot NET Framework

  1. 1. Unit - 5 Roy Antony Arnold G Lecturer Panimalar Engineering College Chennai, India
  2. 2. <ul><li>The .NET platform is a development framework that provides a new application programming interface (API) to the services and APIs of classic windows operating systems while bringing together a number of disparate technologies </li></ul><ul><li>This includes COM+ component services , a commitment to XML and object-oriented design, support for new web services protocols such as SOAP , WSDL (Web Service Definition Language), and UDDI (Universal Description, Discovery, and Integration) and a focus on the Internet, all integrated within the Distributed interNet Applications ( DNA ) Architecture. </li></ul>
  3. 3. <ul><li>The platform consists of four product groups: </li></ul><ul><ul><li>Development tools </li></ul></ul><ul><ul><ul><li>A set of languages, including C# and VB </li></ul></ul></ul><ul><ul><ul><li>A set of development tools including Visual Studio .NET, a comprehensive class library for building web services and web and Windows applications </li></ul></ul></ul><ul><ul><ul><li>As well as the Common Language Runtime (CLR) to execute objects built within this framework. </li></ul></ul></ul><ul><ul><li>A set of .NET Enterprise Servers , formerly known as SQL Server 2000, Exchange 2000, BizTalk 2000, and so on, that provide specialized functionality for relational data storage, email, B2B commerce, etc. </li></ul></ul><ul><ul><li>An offering of commercial web services , called .NET My Services. </li></ul></ul><ul><ul><li>New .NET enabled non-PC devices , from cell phones to game boxes. </li></ul></ul>
  4. 4. <ul><li>Microsoft .NET supports not only language independence , but also language integration . </li></ul><ul><li>This means that you can inherit from classes, catch exceptions, and take advantage of polymorphism across different languages. </li></ul><ul><li>The .NET Framework makes this possible with a specification called the Common Type System (CTS) that all .NET components must obey. </li></ul><ul><li>For example, everything in .NET is an object of a specific class that derives from the root class called System.Object . </li></ul><ul><li>The CTS supports the general concept of classes, interfaces, delegates (which support callbacks), reference types, and value types . </li></ul>
  5. 5. <ul><li>Additionally, .NET includes a Common Language Specification (CLS), which provides a series of basic rules that are required for language integration. </li></ul><ul><li>The CLS determines the minimum requirements for being a .NET language. </li></ul><ul><li>Compilers that conform to the CLS create objects that can interoperate with one another. </li></ul><ul><li>The entire Framework Class Library (FCL) can be used by any language that conforms to the CLS. </li></ul>
  6. 6. <ul><li>The .NET Framework sits on top of the operating system, which can be any flavor of Windows, and consists of a number of components, currently including: </li></ul><ul><ul><li>Four official languages: C#, VB.NET, Managed C++, and JScript.NET </li></ul></ul><ul><ul><li>The CLR, an object-oriented platform for Windows and web development that all these languages share </li></ul></ul><ul><ul><li>A number of related class libraries, collectively known as the FCL </li></ul></ul>
  7. 7. Web Services Web Forms Windows Forms
  8. 8. <ul><li>The most important component of the .NET Framework is the CLR, which provides the environment in which programs are executed. </li></ul><ul><li>The CLR includes a virtual machine, analogous in many ways to the Java virtual machine. </li></ul><ul><li>At a high level, the CLR activates objects, performs security checks on them, lays them out in memory, executes them, and garbage-collects them. (The Common Type System is also part of the CLR.) </li></ul>
  9. 9. Framework Class Library <ul><li>The layer on top of the CLR is a set of framework base classes, followed by an additional layer of data and XML classes, plus another layer of classes intended for web services, Web Forms, and Windows Forms. </li></ul><ul><li>Collectively, these classes make up the FCL, one of the largest class libraries in history and one that provides an object-oriented API for all the functionality that the .NET platform encapsulates. </li></ul><ul><li>With more than 4,000 classes, the FCL facilitates rapid development of desktop, client/server, and other web services and applications. </li></ul>
  10. 10. Framework Base Classes <ul><li>The set of Framework base classes, the lowest level of the FCL, is similar to the set of classes in Java. </li></ul><ul><li>These classes support rudimentary input and output, string manipulation, security management, network communication, thread management, text manipulation, reflection and collections functionality, etc. </li></ul>
  11. 11. Data & XML Classes <ul><li>The data classes support persistent management of data that is maintained on backend databases. </li></ul><ul><li>These classes include the Structured Query Language (SQL) classes to let you manipulate persistent data stores through a standard SQL interface. </li></ul><ul><li>Additionally, a set of classes called ADO.NET allows you to manipulate persistent data. </li></ul><ul><li>The .NET Framework also supports a number of classes to let you manipulate XML data and perform XML searching and translations. </li></ul>
  12. 12. Technologies <ul><li>Extending the Framework base classes and the data and XML classes is a tier of classes geared toward building applications using three different technologies: </li></ul><ul><ul><li>Web Services, </li></ul></ul><ul><ul><li>Web Forms, and </li></ul></ul><ul><ul><li>Windows Forms. </li></ul></ul><ul><li>Web services include a number of classes that support the development of lightweight distributed components, which will work even in the face of firewalls and NAT software. </li></ul><ul><li>Because web services employ standard HTTP and SOAP as underlying communications protocols, these components support Plug and Play across cyberspace. </li></ul>
  13. 13. Compilation and the MSIL <ul><li>In .NET, programs are not compiled into executable files, they are compiled into Microsoft Intermediate Language (MSIL) files, which the CLR then executes. </li></ul><ul><li>The MSIL (often shortened to IL) files C# produces are identical to the IL files that other .NET languages produce. </li></ul><ul><li>C# code is compiled into IL when you build your project. The IL is saved in a file on disk. When you run your program, the IL is compiled again, using the Just In Time (JIT) compiler (a process often called JITing). The result is machine code, executed by the machine's processor. </li></ul><ul><li>The CLS means that all .NET languages produce very similar IL code. As a result, objects created in one language can be accessed and derived from another. </li></ul><ul><li>Thus it is possible to create a base class in VB.NET and derive from it in C#. </li></ul>
  14. 14. JIT Compiler <ul><li>The standard JIT compiler runs on demand . When a method is called, the JIT compiler analyzes the IL and produces highly efficient machine code, which runs very fast. </li></ul><ul><li>The JIT compiler is smart enough to recognize when the code has already been compiled, so as the application runs, compilation happens only as needed. </li></ul><ul><li>As .NET applications run, they tend to become faster and faster, as the already compiled code is reused. </li></ul>
  15. 15. <ul><li>The Web has facilitated distributed applications in a way that was unthinkable even a few years ago, and the trend is toward distribution of responsibility </li></ul><ul><li>A second trend is toward centralizing business logic on large servers . Although these trends appear to be contradictory, in fact they are synergistic : business objects are being centralized while the user interface and even some middleware are being distributed . </li></ul><ul><li>The net effect is that objects need to be able to talk with one another at a distance. </li></ul><ul><li>Objects running on a server handling the web user interface need to be able to interact with business objects living on centralized servers at corporate headquarters. </li></ul>
  16. 16. Definitions <ul><li>The process of moving an object across a boundary is called remoting . </li></ul><ul><ul><li>Boundaries exist at various levels of abstraction in your program. </li></ul></ul><ul><ul><li>The most obvious boundary is between objects running on different machines. </li></ul></ul><ul><li>The process of preparing an object to be remoted is called marshaling . </li></ul><ul><ul><li>On a single machine, objects might need to be marshaled across context, app domain, or process boundaries. </li></ul></ul>
  17. 17. Application Domains & Contexts <ul><li>Processes are divided into application domains (often called app domains); these in turn are divided into various contexts . </li></ul><ul><li>App domains act like lightweight processes , and contexts create boundaries that objects with similar rules can be contained within. </li></ul><ul><li>At times, objects will be marshaled across both context and app domain boundaries, as well as across process and machine boundaries. </li></ul>
  18. 18. Formatter <ul><li>When an object is remoted, it appears to be sent through the wire from one computer to another </li></ul><ul><li>The actual transmission of your message is done by a channel . </li></ul><ul><li>The channel works with a formatter . </li></ul><ul><li>The formatter makes sure the message is in the right format. </li></ul><ul><li>The formatter can translate your message into a right format which can be understand by the remote system. </li></ul><ul><li>The formatter is silently facilitating the communication. </li></ul>
  19. 19. Application Domains <ul><li>Each process is subdivided into one or more application domains . </li></ul><ul><li>An app domain acts like a process but uses fewer resources. </li></ul><ul><li>App domains can be independently started and halted. </li></ul><ul><li>They are secure, lightweight, and versatile. </li></ul><ul><li>An app domain can provide fault tolerance ; if you start an object in a second app domain and it crashes, it will bring down the app domain but not your entire program. </li></ul><ul><li>You can imagine that web servers might use app domains for running users' code; if the code has a problem, the web server can maintain operations. </li></ul>
  20. 20. Methods and properties of the AppDomain class Method or property Details CurrentDomain Public static property that returns the current application domain for the current thread CreateDomain( ) Overloaded public static method that creates a new application domain GetCurrentThreadID( ) Public static method that returns the current thread identifier Unload( ) Public static method that removes the specified app domain FriendlyName Public property that returns the friendly name for this app domain DefineDynamicAssembly( ) Overloaded public method that defines a dynamic assembly in the current app domain
  21. 21. Contd… <ul><li>App domains also support a variety of events—including AssemblyLoad, AssemblyResolve, ProcessExit, and ResourceResolve —that are fired as assemblies are found, loaded, run, and unloaded. </li></ul>Method or Properties Details ExecuteAssembly( ) Public method that executes the designated assembly GetData( ) Public method that gets the value stored in the current application domain given a key Load( ) Public method that loads an assembly into the current app domain SetAppDomainPolicy( ) Public method that sets the security policy for the current app domain SetData( ) Public method that puts data into the specified app domain property
  22. 22. Context <ul><li>App domains themselves are subdivided into contexts . </li></ul><ul><li>Contexts can be thought of as boundaries within which objects share usage rules . </li></ul><ul><li>These usage rules include synchronization, transactions , and so forth. </li></ul><ul><li>Context-Bound and Context-Agile Objects </li></ul><ul><ul><li>Objects are either context-bound or they are context-agile. </li></ul></ul><ul><ul><li>If they are context-bound, they exist in a context, and to interact with them, the message must be marshaled. </li></ul></ul><ul><ul><li>If they are context-agile, they act within the context of the calling object: their methods execute in the context of the object that invokes the method and so marshaling is not required. </li></ul></ul>
  23. 23. Contd… <ul><li>An object has three choices. </li></ul><ul><ul><li>The first option is to be context-agile. A context-agile object operates in the context of its caller. </li></ul></ul><ul><ul><li>Option two is to be context-bound (accomplished by deriving from ContextBoundObject but having no attributes, and thus operating in the context of the creator). </li></ul></ul><ul><ul><li>Option three is to be context-bound with context attributes, and thus operate only in the context that matches the attributes . </li></ul></ul><ul><li>Which you decide upon depends on how your object will be used. </li></ul>
  24. 24. Marshaling Across Context Boundaries <ul><li>No proxy is needed when accessing context-agile objects within a single app domain. </li></ul><ul><li>When an object in one context accesses a context-bound object in a second context, it does so through a proxy, and at that time the two context policies are enforced . </li></ul><ul><li>It is in this sense that a context creates a boundary ; the policy is enforced at the boundary between contexts. </li></ul><ul><li>when you mark a context-bound object with the System.EnterpriseServices.Synchronization attribute, you indicate that you want the system to manage synchronization for that object. </li></ul><ul><li>All objects outside that context must pass through the context boundary to touch one of the objects, and at that time the policy of synchronization will be applied. </li></ul>
  25. 25. Contd… <ul><li>Objects are marshaled differently across context boundaries, depending on how they are created: </li></ul><ul><ul><li>Typical objects are not marshaled at all; within app domains they are context-agile . </li></ul></ul><ul><ul><li>Objects marked with the Serializable attribute are marshaled by value across app domains and are context-agile. </li></ul></ul><ul><ul><li>Objects that derive from MarshalByRefObject are marshaled by reference across app domains and are context-agile. </li></ul></ul><ul><ul><li>Objects derived from ContextBoundObject are marshaled by reference across app domains as well as by reference across context boundaries. </li></ul></ul>
  26. 26. Remoting <ul><li>In addition to being marshaled across context and app domain boundaries, objects can be marshaled across process boundaries, and even across machine boundaries. </li></ul><ul><li>When an object is marshaled, either by value or by proxy , across a process or machine boundary, it is said to be remoted . </li></ul>
  27. 27. Understanding Server Object Types <ul><li>There are two types of server objects supported for remoting in .NET: </li></ul><ul><ul><li>well-known and </li></ul></ul><ul><ul><li>client-activated. </li></ul></ul><ul><li>The communication with well-known objects is established each time a message is sent by the client . </li></ul><ul><li>There is no permanent connection with a well-known object, as there is with client-activated objects. </li></ul><ul><li>Client-activated objects are typically used by programmers who are creating dedicated servers , which provide services to a client they are also writing. </li></ul><ul><li>In this scenario, the client and the server create a connection, and they maintain that connection until the needs of the client are fulfilled . </li></ul>
  28. 28. Types of Well-Known Object <ul><li>Well-known objects come in two varieties: </li></ul><ul><ul><li>singleton and </li></ul></ul><ul><ul><li>single-call. </li></ul></ul><ul><li>With a well-known singleton object , all messages for the object, from all clients, are dispatched to a single object running on the server . </li></ul><ul><li>The object is created when the server is started and is there to provide service to any client that can reach it . These objects must have a parameterless constructor . </li></ul><ul><li>With a well-known single-call object , each new message from a client is handled by a new object . </li></ul><ul><li>This is highly advantageous on server farms , where a series of messages from a given client might be handled in turn by different machines depending on load balancing. </li></ul>