Arquitectura .NET
Total Page:16
File Type:pdf, Size:1020Kb
Distribution and Integration Technologies .NET Architecture Traditional Architectures Web Local Distributed Other applications applications applications applications GUI Network Scripts Data Other Services Services Web Access Services Libraries Execution environment (Posix, Win32, ...) Operating System .NET Architecture 2 Java Architecture Web Local Distributed Other applications applications applications applications Swing Enterprise Java Server JDBC Others Java Beans Pages Standard Java Packages Java Virtual Machine (JVM) Operating System .NET Architecture 3 .NET Architecture Web Local Distributed Other applications applications applications applications Windows Enterprise ASP.NET ADO.NET Others Forms Services .NET Framework Class Library (FCL) Common Language Runtime (CLR) Operating System .NET Architecture 4 Common Language Runtime (CLR) All .NET applications use the CLR The CLR is OO It is independent from high level languages The CLR supports: . A common set of data types for all languages (CTS) . An intermediate language independent from the native code (CIL) . A common format for compiled code files (assemblies) All the software developed using the CLR is known as managed code .NET Architecture 5 Common Type System (CTS) All the languages able to generate code for the CLR make use of the CTS (the CLR implements the CTS) heap There is 2 type categories: string . Value “abcdef” • Simple types stack • Allocated in the stack top class A 41 String: . Reference Double: 271.6 • Complex types • Allocated in the heap • Destroyed automatically by garbage collection .NET Architecture 6 The CTS Object Class ValueType Interface Byte Int16 UInt16 Single Array Char Int32 UInt32 Double UInt64 String Int64 Enum Delegate Decimal Structure Others Boolean Others Reference types Value types .NET Architecture 7 Value and Reference Types class Ref { public int x; } struct Val { public int x; } r1: xx == 58 … v1: x = 5 void Method ( ) { Ref r1 = new Ref( ); r2: Val v1 = new Val( ); r1.x = 5; v2: v1.x = 5; xx == 95 … Ref r2 = r1; Val v2 = v1; r2.x = 8; v2.x = 9; … } Stack Heap .NET Architecture 8 Value and Reference Types Int32: 169 Char: A String: Hello Int16: 43 Stack Heap Value type Reference type .NET Architecture 9 Intermediate Code Compilation Common Source Intermediate Compiler Language code (CIL) For the first time that a method is called Native JIT code compiler Execution .NET Architecture 10 Execution in the CLR Class Y Class X Method 1 1)7) CallsCalls aa methodmethod Method 1 Method 2 Class Z Method 2 Method 3 MethodMétodo 1 Method 3 MethodMétodo 44 Method 2 4) Calls a 8) Calls next 2) Compiles method method . 5) CompilesCIL code 6) Replaces3) Replaces CIL code CIL CILby nativeby native codecode CIL code JIT compiler Native code .NET Architecture 11 Application domains Several .NET applications can run in the same process (CLR) but in different domains The domains are isolated from each other Domains can communicate using some inter process communication techniques Domains can run several threads An application can be made multithreaded easily .NET Architecture 12 Application domains App Domain 1 App Domain 2 Threads Assembly D Assembly A Assembly E Assembly B App Domain 3 Assembly C Assembly F Common Language Runtime An OS process .NET Architecture 13 Application domain and CLR App Domain Assembly Class X Class Y Class Z Method 1 Method 1 Method 1 Method 2 Method 2 Method 2 Method 3 Method 3 Method 4 Metadata for the Classes X, Y and Z Stack Heap Loader JIT Compiler Garbage Collector Common Language Runtime .NET Architecture 14 Assemblies When we do a compilation from a high level .NET language we create modules of managed code One or more modules can constitute an assembly (one or more files) The modules also contain metadata describing types, methods, fields, … One of the assembly modules contains a manifest, describing the assembly components (modules) A private assembly gets installed by a simple copy . There is no registry entries, include files, etc. .NET Architecture 15 Assemblies Class X … Compiler Class Y … (C#,…) Class Z … Class X Class Y Class Z Manifest CIL CIL CIL Metadata for classes X, Y and Z app1.exe Assembly A Class P Class Q Class R Manifest Metadata for classes P and Q Metadata for class R app2.dll app3.netmodule Assembly B .NET Architecture 16 Languages Any language capable of supporting a well defined subset of the CLR/CTS (CLS - Common Language Specification) can be used as a high level .NET language . One of them is the new C# language (follows closely the CTS and CLR specifications) . From Microsoft: VB.NET, C++.NET, J#, F# and JScript.NET . Others: APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme, Smalltalk, Fortran, etc. .NET Architecture 17 Framework Class Library (FCL) It is very broad Accessible from any .NET language It’s written in C# (most of it) It’s organized is several namespaces . Base: namespace System Contains thousands of classes, structs and enums Many more thousands of methods, properties and events .NET Architecture 18 Ports to other platforms For Linux / Solaris / Mac OS: Mono - CLR (with JIT), C# Compiler and other tools and a very substantial part of FCL Cross platform, open source, .NET development framework http://www.mono-project.com For iPhone and iPad (iOS): Xamarin.iOS – Apps with .NET and C# integrated in Xcode and UI designer http://xamarin.com/platform For Android: Xamarin.Android - .NET and C# for Android platform integrated with VS http://xamarin.com/platform .NET Architecture 19.