1 / 49

.Net Framework

.Net Framework. An Overview By: Sukhdeep Sidhu sidhu@cis. Outline. .Net goals .Net concepts Design and compile time Deployment time Execution time Garbage Collection in .Net Summary. Online . Shop Get traffic conditions Compare products Read product reviews. More ?.

morey
Download Presentation

.Net Framework

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 Framework An Overview By: Sukhdeep Sidhu sidhu@cis

  2. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  3. Online • Shop • Get traffic conditions • Compare products • Read product reviews

  4. More ? • Search for restaurants in an area which offer a particular cuisine and have seating available at 7 pm tonight • Look for vendors having a particular item in stock, offering the best price and having the best delivery time • Why is this not possible ?

  5. How to integrate services • XML standard for describing data • .Net: A new development platform infrastructure that will help developers create and deploy distributed applications on the Internet

  6. .Net Goals 1 • Consistent programming model • Simplified programming model • Run once, run always • Execute on many platforms • Language integration • Code reuse • Automatic resource management

  7. .Net Goals 2 • Type safety • Rich debugging support • Consistent error-handling • Deployment • Security

  8. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  9. What is Metadata ? • It is the common format for exposing the information describing a type

  10. An example • What would the metadata of a C++ class describe ? • Methods of the class and their parameters • Data members of the class • Visibility of all class members • The concepts could extend to events the class could fire. • Comparable to .class in java ?

  11. What’s in the Metadata ? • Description of deployment unit (assembly) • Identity: name, version, culture[, public key] • What types are exported • Description of types • What other assemblies it depends on • Security permissions for it to run

  12. What’s in the Metadata ? • Description of types • Name, visibility, base class, interfaces • Members (methods, fields, properties, events, nested types) • Custom attributes

  13. Assemblies • Assembly is the unit of reuse and deployment in .Net • Assemblies can be single-file multi-file. • Consumer – assembly is a named and versioned collection of exported types and resources. • Developer – assembly is a collection of one or more files (HTML pages, metadata files, GIFS etc)

  14. Manifest • Components of an assembly are described in a manifest. Makes the assemblies self-describing • Set of tables that describe the assembly’s identity, culture, files and publicly exported types. Other referenced assemblies are also included

  15. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  16. The right language for the job • MS plans to create four language compilers that target common language runtime – C++ with managed extensions, C#, Visual Basic, JScript. • Non-MS compilers for Cobol, Perl, Pascal, APL, Smalltalk, Scheme. • Rational planning to create Java compiler

  17. The Common Type System • Formal specification of type system implemented by CLR • Possible member of a class – field, method, property and event • Visibility rules • Rules governing type inheritance, virtual functions, object lifetime • All class types must inherit from System.Object

  18. Buiding types into a module • App.cs in C# public class App{ static public void Main( System.String[] args){ System.Console.WriteLine(“Hi”); } } • Compiler generates a PE file (App.exe) containing the CLR header, the metadata and the MSIL

  19. Building types into an Assembly • One of the PE files is selected as the keeper of a manifest or a separate file can contain the manifest. • Example: Add module to an assembly • Two source code files – RUT.cs (rarely used types) and FUT.cs (frequently used types) • Compile RUT.cs into one module (RUT.mod) • Compile FUT.cs into MyTypes.dll (this will be the keeper of manifest • Assembly Linker Utility

  20. RUT module and MyTypes.dll RUT.mod MyTypes.dll RUT.cs methods’ compiled MSIL FUT.cs methods’ compiled MSIL Metadata RUT.cs defined types, methods… RUT.cs referenced types, methods… Metadata FUT.cs defined types, methods… FUT.cs referenced types, methods… Manifest Assembly files (self and RUT.mod) Exported files (self and RUT.mod)

  21. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  22. Assemblies • Assemblies are key to application deployment • Private assemblies – deployed with the application for the sole use of the application. Runtime imposes no administrative policies • Shared assemblies – public-key cryptographic techniques • Guarantee name uniqueness • Secure notion of identity

  23. Deployment • Avoiding the DLL Hell ! • Every assembly self describing through metadata • Every reference to a type is scoped by assembly reference • Well-defined heuristics to locate assemblies • Shared assemblies – Global Assembly Cache

  24. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  25. Common Language Runtime • MSIL instructions cannot be directly executed • MSIL instructions are first compiled into native CPU instructions – JIT compiler

  26. How runtime locates assemblies • Step 1: Initiating the bind • Step 2: Version policy in the application configuration <BindingPolicy> <BindingRedir Name="Calcr" Originator="32ab4ba45e0a69a1" Version="*" VersionNew="2.1.0.0" UseLatestBuildRevision="yes"/> </BindingPolicy>

  27. How runtime locates assemblies • Step 3: Locating Assembly through Codebases or Probing • Codebases • Probing • AppBase (order: .mcl, .dll, .exe) • Search Path • Example

  28. How runtime locates assemblies NAME=MyName APPBASE=http://www.code.microsoft.com SEARCH PATH=bin (The AssemblyResolver changes this to: MyName;bin) LOCALE=de Explicit Codebases: Binding context CODEBASE=http://www.all.code.microsoft.com/codebase.exe App.cfg CODEBASE=[none] Probing URLs: • http://www.all.code.microsoft.com/codebase.exe • http://www.code.microsoft.com/MyName.MCL • http://www.code.microsoft.com/MyName.DLL • http://www.code.microsoft.com/MyName.EXE • http://www.code.microsoft.com/MyName/MyName.MCL • http://www.code.microsoft.com/MyName/de/MyName.MCL • http://www.code.microsoft.com/bin/MyName.MCL • http://www.code.microsoft.com/bin/de/MyName.MCL • http://www.code.microsoft.com/MyName/MyName.DLL • http://www.code.microsoft.com/MyName/de/MyName.DLL • http://www.code.microsoft.com/bin/MyName.DLL • http://www.code.microsoft.com/bin/de/MyName.DLL • http://www.code.microsoft.com/MyName/MyName.EXE • http://www.code.microsoft.com/MyName/de/MyName.EXE • http://www.code.microsoft.com/bin/MyName.EXE • http://www.code.microsoft.com/bin/de/MyName.EXE

  29. How runtime locates assemblies • Step 4: The Global Assembly Cache and Auto-QFE policy • Step 5: Administrator Policy • Version policies specified by the administrator

  30. JIT compilers • Normal compiler • Examine’s a method’s MSIL • Optimizes the resulting native code just like the back end of an unmanaged compiler • Economy compiler • On machines where cost of using memory and CPU cycles is high • Replaces each MSIL instruction with its native code counterpart

  31. Verification and Security 1 • Code Identity – through class loader or interoperability services • Type safety – access only memory that has been allocated for their use and access objects only through their exposed interfaces • Combine strong typing in metadata with strong typing in MSIL

  32. Verification and Security 2 • Code Access Security • Resource Permissions – CLR walks up the call stack to check if all assemblies have required permissions • Identity permissions – Site, Zone, Shared Name, Publisher • Declarative security – load time or runtime

  33. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  34. Resource allocation • All resource allocated from a managed heap

  35. The Garbage Collection Algo 1 • Makes a graph of accessible objects

  36. The Garbage Collection Algo 2 • Collect the unaccessible objects

  37. Finalization • Object can gracefully clean up itself • Downsides: • Objects take longer to allocate • Performance is affected • No guarantee of order or execution • resurrection

  38. Finalization Internals 1 • Before garbage collection

  39. Finalization Internals 2 • Heap after garbage collection

  40. Finalization Internals 3 • Heap after Second gabage collection

  41. Weak References • Weak references allow the garbage collector to collect the object • To access the object, the application must obtain a strong reference to the object • Long/Short weak references

  42. Generational garbage collector 1 • Also called ephemeral garbage collector • Based on following assumptions: • Newer the object, shorter its lifetime • Older the object, longer its lifetime • Newer objects strongly related and are frequently accessed around the same time • Compacting a portion of the heap faster than compacting the whole heap

  43. Generational garbage collector 2 • Initially all objects in generation 0 • Any objects surviving a garbage collection are considered to be generation 1 • New objects are always added to generation 0 • Generation incremented when an object survives the garbage collection (currently generation 2 is the highest)

  44. Generational garbage collector 3 • Performance optimizations • Collect only from generation 0 • If more memory required, proceed to higher generations

  45. Issues in garbage collection • Multi-threaded applications • Fully interruptible code • Hijacking – modifying the thread’s stack so that the return address points to a special function • Safe points • Synchronization free allocations • Scalable collections

  46. Outline • .Net goals • .Net concepts • Design and compile time • Deployment time • Execution time • Garbage Collection in .Net • Summary

  47. Summary • Enables building and deploying of web services and applications in any programming language • Bind applications over the Internet that take advantage of existing infrastructure and applications • A new platform for building integrated service-oriented applications for Internet Businesses.

  48. References • Jeffrey Richter’s articles in MSDN magazine: • http://msdn.microsoft.com/msdnmag/issues/0900/Framework/Framework.asp • http://msdn.microsoft.com/msdnmag/issues/1000/Framework2/Framework2.asp • http://msdn.microsoft.com/msdnmag/issues/1100/GCI/GCI.asp • http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/GCI2.asp • http://msdn.microsoft.com/msdnmag

More Related