Microsoft .NET - PowerPoint PPT Presentation

microsoft net l.
Skip this Video
Loading SlideShow in 5 Seconds..
Microsoft .NET PowerPoint Presentation
Download Presentation
Microsoft .NET

play fullscreen
1 / 69
Download Presentation
Microsoft .NET
Download Presentation

Microsoft .NET

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Microsoft .NET Gaurav Gupta Dinesh Chandnani CSc 630 Spring 2002

  2. Acknowledgements • Microsoft MSDN • Microsoft GotDotNet • Sun Microsystems • Csharp Help • Sam Gentiles Website • Brinkster Web Hosting • DotNetBuzz • .netWire • The IT Portal • .NET Experts CSc 630: Microsoft .NET

  3. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  4. Microsoft Vision Empower people, any time, any place,and on any device through great software CSc 630: Microsoft .NET

  5. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  6. .NET Design Goals • Unifies programming models • Dramatically simplifies development • Provides robust execution environment • Supports multiple programming languages • Natively supports XML Web Services CSc 630: Microsoft .NET

  7. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  8. VB C++ C# JScript … Visual Studio.NET Common Language Specification ASP.NET: Web Services and Web Forms WindowsForms ADO.NET: Data and XML Base Class Library Common Language Runtime The .NET Framework CSc 630: Microsoft .NET

  9. Terminology "ABC" • CLR: Common Language Runtime • One runtime for many programming languages • Assembly • Container for code, metadata and resources—your new term for what you used to call “D-L-L“ • Intermediate Language(IL) • One intermediate, high-level assembly-style language that is emitted by language compilers • Metadata • Information that describes the shape of data and the runtime behavior of a program CSc 630: Microsoft .NET

  10. Source code VB C# C++ Unmanaged Component Compiler Compiler Compiler Managed code Assembly IL Code Assembly IL Code Assembly IL Code Common Language Runtime JIT Compiler Native Code Operating System Services Execution Model: CLR CSc 630: Microsoft .NET

  11. Common Language Runtime • Robust and secure execution environment • Type safe, garbage-collecting • Common for multiple languages • Deep-integration options • Simplifies deployment and management • No registry involved, zero-impact install • Side-by-site execution of multiple versions • Potentially Multi-Platform ? CSc 630: Microsoft .NET

  12. Common Language Runtime • Execution environment for "managed code" • Managed? • Code resides on disk as IL • Must be translated into machine code • Code references other code • Other code residing in other assemblies must be found • Memory must be managed • .NET employs a garbage collector to do that job • Execution must be as secure as possible • Safeguard code against viruses and worms CSc 630: Microsoft .NET

  13. Assembly Language Compiler Native Code JIT Compiler Execution CLR Execution Model: Conceptual Compilation Code (IL) Source Code Metadata Before installation or the first time each method is called CSc 630: Microsoft .NET

  14. Assembly • Assemblies • contains the code that CLR executes • functional building blocks • self-aware • retrieve any dependant assemblies • does not execute without Assembly Manifest CSc 630: Microsoft .NET

  15. Assembly • Assemblies are loadable entities containing • Assembly metadata • Type metadata • MSIL code • Resources • Assemblies contain: • Modules • Consists of one or multiple physical files • Bundled by a "packing list": The Manifest CSc 630: Microsoft .NET

  16. Manifest: Standard Elements • Manifest is a table with information records • Manifest contains information about: • Assembly name • Version information • Processor and OS • Files that make up this assembly • References to types and resources CSc 630: Microsoft .NET

  17. Modules • Module is a compiled unit • Modules contain metadata and IL • Metadata describes structure • IL describes runtime behavior • Modules cannot be loaded independently • Must be contained in assembly CSc 630: Microsoft .NET

  18. Intermediate Language (IL) • .NET languages are compiled to an Intermediate Language (IL). • CLR accepts the IL code and recompiles it to machine code. • The recompilation is just-in-time (JIT) meaning it is done as soon as a function or subroutine is called. • The JIT code stays in memory for subsequent calls. • In cases where there is not enough memory it is discarded. CSc 630: Microsoft .NET

  19. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  20. .assembly hello {} .assembly extern mscorlib {} .method static public void main() il managed { .entrypoint .maxstack 1 ldstr "Hello World from IL!" call void [mscorlib]System.Console::WriteLine(class System.String) ret } MSIL: Hello World class HelloWorld {public static void Main() {System.Console.WriteLine("Hello World");   } } CSc 630: Microsoft .NET

  21. Metadata • A type must be self descriptive: It must describe properties and methods that it exposes. • Examples: • The type Integer describes what values it takes and what operations it accepts. • The type Check describes what values (e.g., AccountNo and Amount) it takes and what operations (e.g., Cash, Deposit) it accepts. CSc 630: Microsoft .NET

  22. .NET JVM: CLR • JIT (Just-In-Time) • compiles methods • caches the native code • Verify MSIL to be type safe • Managed code can contain platform specific calls and dependencies. CSc 630: Microsoft .NET

  23. Common Type System CSc 630: Microsoft .NET

  24. .NET Class Library • In traditional environments different categories of services are provided to the programmer via libraries such as: C run time library, Win32 APIs, I/O and database access libraries, etc. • These libraries are language dependent, operating system dependent, and often contain simple subroutine calls as opposed to self describing types. • In .NET all services fall into a single, hierarchy organized, language independent class library CSc 630: Microsoft .NET

  25. Generation 1 Generation 0 The Collector In Action • New heap begins with new generation • Accessible references keep objects alive • Preserves / Compacts referenced objects • Objects left merge with older generation • New allocations rebuild new generation CSc 630: Microsoft .NET .NET-25 CSc 630: Microsoft .NET

  26. Garbage Collection • The CLR includes garbage collection. • Managed heap always points to the next available spot, so allocation speed is closer to stack allocation. • Memory is allocated successively, resulting in fewer page faults and improved cache use. • System.GC gives access to the GC: GC::Collect(int generation) etc. CSc 630: Microsoft .NET

  27. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  28. Visual Studio .NET • Supports multi-language • Designs applications more quickly • Builds solutions with rule-enforcement templates • Tests applications for stability CSc 630: Microsoft .NET

  29. VS.NET Core Languages • Visual Basic • Substantial language innovation • First class .NET language • Leverage existing skills • C# • More productive C/C++ language for .NET • Full RAD support • Visual C++ • Still most powerful and flexible language • Enables incremental migration to .NET CSc 630: Microsoft .NET

  30. Perl Python COBOL Eiffel Haskell ML JScript Ada APL C Other Languages. . . • Pascal • C++ • Visual Basic • C# • SmallTalk • Oberon • Scheme • Mercury • Objective Caml • Oz CSc 630: Microsoft .NET

  31. C# • Modern object oriented, type-safe, garbage collected • Familiar to C/C++ programmers. • Integrated COM, Platform API, and XML support • No class libraries, uses only common .NET libraries • Implementation of a new language with full support for the .NET framework. CSc 630: Microsoft .NET

  32. C# C# Java Class structure Single inheritance Interfaces Garbage Collection Code safety Reflection JavaDoc Convenience & Additional Features Properties Indexes Attributes Delegates C++ Feature richness, Direct access to memory Legacy keywords CSc 630: Microsoft .NET

  33. Public interface Icalc { int add(int x, int y); int subtract(int x, int y); } Public class Calculator : Icalc { int add(int x, int y) { return x + y; } int subtract(int x, int y) { return x-y; } } Interface and Class in C# CSc 630: Microsoft .NET

  34. Public Interface Icalc Function Add(X As Integer, Y as Integer) Function Subtract(X As Integer, Y as Integer) EndInterface Public Class Calculator Implements ICalc Function Add(X as Integer, Y as Integer) Implements Icalc.Add Add = x + y End Function Function Subtract(X as Integer, Y as Integer) Implements Icalc.Subtract Subtract = x – y End Function End Class Interface and Class in VB.NET CSc 630: Microsoft .NET

  35. C++ • Managed C++ can be used to write .NET Framework applications • It relies on extensions to the standard language • C++ will be important for non-Framework-based applications • The core semantics of C++ does not match with CLR CSc 630: Microsoft .NET

  36. Cross-Language Interoperability ‘This is a VB.NET code Namespace MyCSClass Public Class CSClass Public Sub CSClass() 'code End Sub ‘returns the length of the passed string Public MyMethod(str As String) As Integer MyMethod = str.Length; End Sub ‘returns n squared Virtual Public MyVirtualMethod(n As Integer) As Integer MyVirtualMethod = n*n; End Sub End Class CSc 630: Microsoft .NET

  37. #using "MyCSClass.dll" usingnamespace MyCSClass; CSClass *cs = new CSClass(); // will return 11 int result; result = cs->MyMethod("Hello World"); // will return 2 squared result = cs->MyVirtualMethod(2); Cross-Language Interoperability Can use components written in different languages How ? CSc 630: Microsoft .NET

  38. Cross-Language Inheritance • Derive a new class in language C from MyClassclass NewClass : public MyCSClass::CSClass • Override virtual method. . . • virtual int MyVirtualMethod( int param ) • And access your new class normally. . . • NewClass *newCls = new NewClass();result = newCls->MyVirtualMethod(param); • All this without the source code to the previous • component or knowledge of it s language. class CPPClass : public MyCSClass::CSClass { public: // returns the cube of the given number virtualint MyVirtualMethod(int n) { return n*n*n; } }; CSc 630: Microsoft .NET

  39. Cross-Language Features Support across components and languages: • Inheritance • Exception handling • Debugging • Good for extending 3rd party components in the language of your choice. CSc 630: Microsoft .NET

  40. Visual Basic Form as a Class • All .NET languages use the same tools (WinForms) to create the user interface of an application as a form • A form a class containing other classes (called controls) such as TextBox, ListBox or Button • The act of drawing a form (such as Form1) generates the VB.NET code that defines the corresponding class named Form1 • As a class, Form1 has methods, properties, and events. • Form1.Show is a method that displays the Form1 on the screen. • Form1.EmpName.Text references the contents of the TextBox EmpName in Form1. • EmpName_Change is the name of the event handler that is invoked when the user changes contents of EmpName TextBox. CSc 630: Microsoft .NET

  41. Server-Side Controls • ASP and JSP provide a language to generate HTML markups. In ASP.NET the complexity of this language is significantly reduced by using server-side controls. • For each HTML control there exists a server-side control in ASP.NET. CSc 630: Microsoft .NET

  42. <script runat="server" language="vb"> Public Sub doClick(sender as object, e as EventArgs) TheLabel.Text = "Hello, world! (from ASP.NET in VB NET,code inline)" End Sub </script> <html> <head><title>In-line ASPX file in VB .NET </title></head> <body> VB .NET ASP.NET application with inline code<P><P> <form runat="server"> <asp:button runat="server" text="Say Hello" onclick="doClick" /> <p> <asp:label runat="server" text="" id="TheLabel" /> </form> </body> </html> VB.NET ASP.NET APPLICATION CSc 630: Microsoft .NET

  43. <script runat="server" language="C#"> void doClick(object sender, EventArgs e) { TheLabel.Text = "Hello, world! (from ASP.NET in C#, code inline)"; } </script> <html> <head><title>In-line ASPX file in C#</title></head> <body> C# ASP.NET application with inline code<P><P> <form runat="server"> <asp:button runat="server" text="Say Hello" onclick="doClick" /> <p> <asp:label runat="server" text="" id="TheLabel" /> </form> </body> </html> C# ASP.NET APPLICATION CSc 630: Microsoft .NET

  44. Why another Data Access API? • Most new applications are • Loosely coupled - even disconnected • More and more use XML to encode data • This is very different from the classical connected, tightly coupled client/server model CSc 630: Microsoft .NET

  45. Mapping ADO.NET & XML Integration Visual Studio.NETDesigners & Controls XSLT, XpathValidation XMLDataDocument DataSet ManagedProvider XMLReader XMLTextReader XMLNodeReader XMLDocument XML Stream SQL Server CSc 630: Microsoft .NET

  46. .NET and DOM XmlDocument doc = newXmlDocument(); doc.Load( "test.xml" ); XmlNode root = doc.DocumentElement; foreach( XmlNode personElement in root.ChildNodes ) Console.WriteLine( personElement.FirstChild.Value.ToString() ); Fred Bill <PEOPLE> <PERSON>Fred</PERSON> <PERSON>Bill</PERSON> </PEOPLE> CSc 630: Microsoft .NET

  47. .NET and XPath // This is C# code XPathDocument xpdoc = new XPathDocument("test.xml"); XPathNavigator nav = xpdoc.CreateNavigator(); XPathExpression expr = nav.Compile("descendant::PEOPLE/PERSON"); XPathNodeIterator iterator = nav.Select(expr); while (iterator.MoveNext()) Console.WriteLine(iterator.Current); CSc 630: Microsoft .NET

  48. Outline Microsoft Vision • .NET Design Goals • .NET Framework • Visual Studio.NET • Web Services • .NET vs J2EE • Conclusion CSc 630: Microsoft .NET

  49. Users store, access and share based information anytime, any place, from any device XML Web Service Message Developers create and deliver compelling solutions to huge customer base Operators run efficient, secure, and reliable data centers for their user base What is .NET Web Services ? Internet CSc 630: Microsoft .NET

  50. .NET Web Services <%@ WebService Language="C#" Class="Hello" %> /* Hello.asmx */ using System.Web.Services; public class Hello: WebService { [ WebMethod ] public string IssueGreeting() { return "Hello, World!"; } } CSc 630: Microsoft .NET