1 / 50

.NET Session

.NET Session. Prepared By :. Manu Sharma. IBE Team. Topics. Types of .NET Applications .NET Framework CLR Garbage Collection Importance of .NET. .NET Applications. .NET Applications. Console Applications GUI Applications Windows Applications Web based Application Library of Types

inari
Download Presentation

.NET Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .NET Session Prepared By : Manu Sharma IBE Team

  2. Topics • Types of .NET Applications • .NET Framework • CLR • Garbage Collection • Importance of .NET

  3. .NET Applications

  4. .NET Applications • Console Applications • GUI Applications • Windows Applications • Web based Application • Library of Types • Windows Services • Web Services

  5. .NET Framework

  6. .NET Architecture ….. VC++.NET VJ# VB.NET C# Windows Forms XML Web Services Web Forms ASP.NET .NET Framework Class Library Common Language Runtime Win 32

  7. Defining the .NET Framework • The .NET Framework is • A software development environment • A runtime engine for Managed Code • A platform designed for Internet-Distributed software • The .NET Framework is an exciting new computing platform

  8. Internet Distributed Software Second-Tier(database or other server) Second-Tier Second-Tier Web Server Web Server Client Client

  9. .NET Framework Features • Cross Language Compatibility • Platform Independent • CTS (Common Type Specification)

  10. Cross Language Support • The .NET Framework supports many languages • Any compiler can be modified to emit managed executables • IL and metadata • Languages that target the .NET Framework • C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk • Dozens more existing and on the way • Regardless of source language, all managed code can • Use the same tools • Use the same reusable components • Take advantage of features of the CLR • Developers use their language of choice

  11. Platform Independent Support • .NET Linux Development tool has been created to date (Mono & DotGNU) • Mono • Primary Component is CLR which executes .net Byte-code (MSIL) • Same as Java Runtime Environment. • DotGNU • More Focused on Web Service area of .NET

  12. Common Type Specification • As .NET Application are converted into IL prior to deployment and execution,thus all primitive data types are represented as .NET data type • VB.Net(Integer)=C#(int)=System.Int32(.NET Type)

  13. Components of .NET Framework • CLR (Common Language Runtime) • FCL ( Framework Class Library)

  14. Introducing the Common Language Runtime

  15. Managed Code and the CLR • The Common Language Runtime (CLR) is a runtime engine • Manages .NET Code (such as C# applications) • Provides features such as memory management, thread management, object type safety, security, etc. • Is a part of the .NET Framework

  16. The CLR and Managed Code Legacy Software(unmanaged code) Managed Executable Reusable Managed Components Common Language Runtime(JIT compilation, memory management, etc.) Windows (or other operating oystem)

  17. What is Managed Code • Code that targets the CLR • C#, VB.NET, PERL, Java, C++, Cobol, etc. • All Managed code has all features of CLR • Object oriented • Internet oriented • Access to the Framework Class Library (FCL) • All Managed executables consist of • Intermediate Language (IL) instructions • Metadata

  18. IL and Metadata • IL • CPU independent machine language • Just-in-time compiled at runtime • Metadata • Structured information • describes programming constructs including • Classes definitions, field and method definitions, parameter lists, return types, etc.

  19. ILDasm.exe • Use ILDasm.exe to view IL for managed executable

  20. Just-in-Time Compiling • All managed code runs in native machine language • All managed code is made up of IL and metadata • The CLR JIT-compiles the IL and metadata • At execution time • Executed directly by CPU • Allows for the best of both worlds • Code management features • Performance of full-speed execution

  21. SomeSource.cs using System.Windows.Forms; using System.Drawing; class MyForm:Form{ public static void Main(){ Application.Run( new MyForm()); } protected override void OnPaint( PaintEventArgs e){ e.Graphics.DrawString( "Hello World!", new Font("Arial",35), Brushes.Blue, 10, 100); SomeSources.exe IL Metadata From Source Code to Managed .exe C# Compiler A Managed Application

  22. SomeSources.exe IL Metadata Executing a Managed Application At execution time the IL and Metadata are JIT compiled Running Process’ Memory JIT Compiler Native Machine Language 10010100 10110000 10000000 10111010 11011011 11010111 11000010 01110110 The CPU executes the JIT- compiled machine code directly

  23. The Common Language Runtime • The Common Language Runtime (CLR) • Execution engine of The .NET Framework • Offers many system services • Similar to an OS • Runs on a host OS • The .NET Framework • New platform by Microsoft • Designed to target the Internet

  24. The Purpose of the CLR… • Safe binary execution • Security, memory protection • Running un-trusted code, locally • Performance and Functionality • Native execution (JIT Compiled)

  25. …The Purpose of the CLR • Bug reduction • More code interacting, bugs affect more users • Ease of integration • Developer investment • Reuse skills from project to project, even if the projects are vastly different

  26. Managed Code and the CLR • The Common Language Runtime (CLR) is a runtime engine • Manages .NET Code (such as C# applications) • Provides features such as memory management, thread management, object type safety, security, etc. • Is a part of the .NET Framework • Managed code • Code that targets the CLR • Any .NET Language, including C#, Visual Basic, C++, Java, Cobol, etc. • The CLR and Managed Code

  27. IL and Metadata • All Managed executables consist of • Intermediate Language (IL) instructions • Metadata • IL • CPU independent machine language • Just-in-time compiled at runtime • Metadata • Structured information • describes programming constructs including • Classes definitions, field and method definitions, parameter lists, return types, etc.

  28. Automatic Memory Management • The CLR manages memory for managed code • All allocations of objects and buffers made from a Managed Heap • Unused objects and buffers are cleaned up automatically through Garbage Collection • Some of the worst bugs in software development are not possible with managed code • Leaked memory or objects • References to freed or non-existent objects • Reading of uninitialized variables • Pointerless environment

  29. Garbage Collection class MyClass{ void Method(){ Variable v1; Variable v2; do{ . . . The Managed Heap B A E C Objects A and D will be cleaned up because neither is directly or indirectly referenced by code D = Object or buffer in memory

  30. Garbage Collection • Garbage collection occurs when a new operation fails due to lack of memory • All managed threads are stopped • Collection starts with roots, and recursively finds referenced objects • Roots == globals, locals, cpu registers • Referenced objects are moved down in the managed heap, • Making space available at the end • Removing unreachable objects • No Fragmentation • References fixed-up and managed threads restarted

  31. Types of Managed Applications • Common application • GUI or windowed applications (Windows.Forms) • Console applications or command line apps • Web applications (ASP.net) • Web forms applications • Web services • Scripted code • Applications like word processors or database servers can host the CLR • Use any managed language (C#, VB, etc.) as a script or macro language • Wherever you use managed code • Same compilers and tools • Same FCL • Same CLR (JIT compiled, object oriented, memory managed, etc.

  32. CLR Summary • The platform for managed code • C#, VB.NET, etc. • Features • Memory management, security management, reflection, type safety • IL, metadata, JIT compilation • Assemblies, managed modules • Understanding the platform will make coding .NET code easier • C#, VB.NET, etc.

  33. Introducing the Framework Class Library

  34. The Framework Class Library • A huge collection of reusable types • Classes, interfaces, enumerations and structures • For use by any managed code • Including code written in any managed programming language • Types for • Common tasks such as collections, file IO, memory and thread management • GUI and window manipulation • Web form and web service applications • Totally object oriented toolbox for developers • Ships as part of the .NET Framework

  35. Using the FCL • Types are arranged in a hierarchy of Namespaces • A type’s full name includes its namespaces • Form class is actually System.Windows.Forms.Form • Use using to indicate namespaces in source code • Assembly references are necessary for many types • The SDK documentation is critical for using SDK types • Includes descriptions • Often includes useful code samples • Indicates namespaces and assemblies for types

  36. Assembly vs. Managed Module • Deployment of managed code broken-up into to logical concepts • Assembly • Managed module • Managed module • Single physical file • Contains type definitions • Cannot be executed or used directly • Assembly • Unit of versioning, deployment, and security • Can consist of multiple files • Managed modules • Resource files

  37. Reasons for Assemblies • Decouple concepts of physical and logical deployment • Logically, you deploy a complete assembly • Physically, deploy only necessary files • Performance enhancement for network deployment • Include resource files • No embedding • Resource files retain their identity • Smiley.jpg, Info.xml, etc.

  38. Versioning Assemblies • Assemblies can be strongly named • Includes public/private key information • Strong named assemblies bind by version • Code that uses V1 uses V1 even after V2 is installed on the system • Avoids DLL hell • Gives you the freedom to make V2 components incompatible with V1 • Strong binding is a major improvement over DLLs

  39. Top 10 Reasons to Move to .NET

  40. In the past, the Microsoft architecture has been built on COM/DCOM, a binary standard for allowing cross-process communication that standard didn't have any relevance outside the Microsoft world ADO Recordset also saves data in Binary Format and Binary Format has no meaning for non Microsoft Environment. .Net uses completely standards-based like Xml linked with XSD so that client can validate the data. SOAP is an XML-based protocol that communicates with Web services. The integration of SOAP allows for easy programmatic access by any client, whether or not that client is running a Microsoft operating system. Reason 1 Standards integration XML, SOAP, and more

  41. COM makes extensive use of the Windows Registry to locate components on the machine. The concept was good, but there would only ever be a single instance of a component registered, and all applications would use the same version. COM promised to have new versions maintain backwards compatibility with old versions, but developers were free to break this compatibility, and sometimes did. .Net doesn't use the registry, most deployments can simply be done with a copy command. There's often no need to develop installation files. Also, Web applications don't lock assemblies, so you don't have to shut down an application to update a DLL. Reason 2 Ease of Deployment

  42. Microsoft is on the Web service bandwagon in a major way, and it's never been easier to develop Web services than it is with .Net. You can create simple Web services with Notepad and not even have to run them through a compiler; simply call them and .Net compiles them and even generates a test page so you can verify they are working. .Net has all the plumbing needed and generates all the files you need, such as the WSDL file. .Net is also a smart consumer of Web services: Once you set a reference to a Web service, you treat it just like a local assembly. You get full Intelligence and function completion help. Reason 3 Web service support

  43. User finally have an integrated set of tools for all your languages like VB.NET,C# etc. Reason 4 Standard toolset for any .Net language

  44. Soon after the release of Visual Studio .Net, Microsoft released the Microsoft Mobile Internet Toolkit (MMIT) for building mobile applications using .Net. This allows you to visually drag and drop controls on forms aimed at mobile devices. The toolkit handles writing the proper markup language (e.g., WML, WAP, and so forth). Coming soon will be the .Net Compact Framework, a scaled-down version of the Framework designed to run on Pocket PC devices. This will enable developers to create rich applications to run on Pocket PC computers. Reason 5 Support for mobile devices

  45. Reduces Bugs Build More Scalable Applications .Net handles Allocating and recovering memory Creating and destroying threads and processes handling the access permissions of the running code. Reason 6 Managed code

  46. .NET Application can also be build and executed in other platforms like LINUX Reason 7 Platform Independent

  47. Net has probably spawned more books than any other programming technology. There are a number of Web sites that provide techniques and tutorials for developers moving to .Net. Reason 8 No lack of learning resources

  48. Completely OOPS The languages were built with an n-tier, component-based approach in mind. Reason 9 Modernized languages

  49. One of the banes of VB developers has been that a string in VB was not the same as a string in C++, so when calling Windows API functions, there could be some problems. .Net specifies a standard definition for all types, so a string in VB.Net is the same as a string in C#, which is the same as a string in netCOBOL .Net. Reason 10 Standard base types across languages

  50. THANKS Prepared By : Manu Sharma IBE Team

More Related