1 / 40

Understanding Microsoft Assemblies in .NET: Requirements Analysis, Design Framework, Architecture, Detailed Design, Impl

This chapter discusses the key concepts of Microsoft Assemblies in .NET, including requirements analysis, design framework, architecture, detailed design, and implementation. It explores the components of .NET manifests, versioning attributes, private and shared assemblies, and creating assemblies using C#.

raleighr
Download Presentation

Understanding Microsoft Assemblies in .NET: Requirements Analysis, Design Framework, Architecture, Detailed Design, Impl

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. Chapter 12Microsoft Assemblies

  2. Process Phases Discussed in This Chapter Requirements Analysis Design Framework Architecture Detailed Design Implementation Key: = main emphasis = secondary emphasis x x Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  3. Learning Goals for This Chapter Understand … • … Microsoft’s component (“assembly”) architecture • … where assemblies fit in .NET • … required rudiments of C# • … the contents of .NET manifests, including: Versioning Attributes • … the difference between private and shared assemblies • … create assemblies using C# Be able to … Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  4. .NET Goals and Solutions • Create interoperable components from multiple source languages • C++, Visual Basic, …. • Solve multiple component version clashes • “dll hell”: naming confusion in COM • Define a common runtime • Avoid registry • Necessity to register components with host computer Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  5. Design Goal At Work: Reusability Microsoft wanted to allow developers to create interoperable components using their favorite source languages. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  6. The Parts of.NET Web tools and Languages ASP.NET, Windows Forms; Visual Basic.NET, C# uses .NET Framework Classes . . . . net XML IO Security uses Common Language Runtime (CLR) . . . . Memory Management Common Type System (CTS) Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  7. Types in the CTS • Boolean • DateTime • Decimal – 28 significant digits • Double – 64-bit double-precision floating point • GUID – unique 128-bit integer; unique identifier • Int16, Int32, Int64 • Sbyte – 8-bit signed integer –128 to +127 • Single – 4-byte single precision floating point • TimeSpan – a period of time Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  8. Methods of System.Object • Boolean Equals( Object ) • Int32 GetHashCode() • Generates an integer corresponding to the value of the object • Used by sorting algorithms in System.Collections • Type GetType() • for the Reflection API • String ToString() Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  9. Collections ComponentModel “to implement the runtime and design time behavior of components” Data To deal with databases via ADO Drawing IO Net to interface with common network protocols Reflection Runtime Selected System.XX .NET Framework NameSpaces • Security • Text • ASII, Unicode etc. • Threading • Web • WinForms • XML Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  10. Compilation Process in .NET Base class library Ancillary info Compiler & metadata generator Class loader IL and metadata Source Code .dll or .exe C++ VB C# IL compiler J#, Java (3rd parties) native code Process File Key: execute Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  11. The Parts of a .NET Assembly (Component) Manifest • Identity • name • version • Names of files • Encrypted hash of files to ensure integrity • Specification of types defined • Names of referenced assemblies • Specification of required security permissions Source Files A .NET assembly: xyz.dll A File Microsoft Intermediate Language (IL) A File A File A File Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  12. Key Concept: A .NET Assembly -- includes class code from multiple files, in IL form, described by a manifest. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  13. C# Goals 1 of 2 • Rapid application development • as with JavaBeans • Cross-platform deployment • generates character stream interpreted by .Net runtime. • as with Java Virtual Machine • Access to platform-native resources • take advantage of the Windows API to run as a full-featured application on Windows 2000 • Support for the COM and .NET platforms Unlike Java Unlike Java Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  14. C# Goals : 2 of 2 • Features of C and C++ “with the functional ease of rapid application development tools.” • Components with properties, methods and events • built in Unlike Java Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  15. HelloWorld Output Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  16. Selected C# Features • Automatic garbage collection • Allows developers to disable garbage collection locally – • by marking code as “unsafe” • (e.g., where real time performance required?) • Eliminates pointers in favor of references • Introduces Interfaces Unlike Java Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  17. C# Web Features: Web Services • Attribute library allows wrapping of C# classes and functions as Web services. • a hosted software module callable over the Internet typically via SOAP protocol. • SOAP wraps method calls, parameters, and return values, in XML packets. • Using appropriate attributes, programmer can turn any C# class or function into a Web service. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  18. Creating a .NET Component 1 of 2 C# compilation Input file csc /t:library /out:hello.dll helloFile.cs “output” Component (output) name “target” Create a library component: Don’t seek Main() Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  19. Creating a .NET Component (“Assembly”) 2 of 2 helloFile.cs csc /t:library /out:hello.dll helloFile.cs hello.dll hello.dll Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  20. Using a .NET Component helloClient.cs hello.dll csc /r:hello.dll /out:helloApp.exe helloClient.cs helloApp.exe … now execute helloApp. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  21. Creating a .NET Component Containing Multiple Classes GreetingUtility HelloClass AuRevoirClass HelloAuRevoirComponentSource.cs csc /t:library /out:helloAuRevoir.dll HelloAuRevoirComponentSource.cs helloAuRevoir.dll Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  22. Output For “Multiple Class” Example Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  23. Uses for Metadata Using metadata allows the CLR to support: • Multiple execution models • interpreted, • JITted (Just-in-time) • native • legacy code (prior to .NET) • Uniform services available to debuggers, profilers etc. • Consistent exception handling • Code access security • Memory management • Reflection • Interoperability with existing unmanaged COM applications • Interoperability with existing unmanaged code • Optimization to match the particular CPU or environment. Amended from http://msdn.microsoft.com/library/default.asp Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  24. Manifest of Component helloAuRevoir.dll Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  25. Manifest Contents for helloAuRevoir.dll Component • - • - • - • - • - • - • - • - • - • - • - • - • - • - • - • -- Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  26. Manifest Detail of sayHelloWorld() in HelloClass • - • - • - • - • - • - • - • - Recall the source: public void SayHelloWorld( ) { GreetingUtility.OutputMessage ( "Component says: Hello World" ); } Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  27. The Version Field of an Assembly • Major version • Minor version • Revision • Build number Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  28. Versioning (The process of evolving a component over time in a compatible manner.) A new version is … • … source compatiblewith a previous version if code that depends on the previous version can, when recompiled, work with the new version. • … binary compatible if code that depended on the old version can, without recompilation, work with the new version.” (adapted from Microsoft) Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  29. Attributes in .NET • Metadata: about … • … variables • … classes • … functions • Types of attributes: • Built-in • User-defined • Available at runtime Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  30. Output of main() in ConditionalDemo with #define DEBUG without #define DEBUG Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  31. Output For Authorship Querying Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  32. Key Concept: A .NET Manifest Lists … .. the files containing the IL-compiled classes, the .NET components on which the assembly depends, version numbers, attributes, and encrypted hash to verify not tampered in transit. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  33. Design Goal At Work: Reusability We want to reuse an assembly, confident it is the one it’s supposed to be. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  34. Using NameSpaces Implement applications 1and 2. Exploit common components. • Application 1: List available flights in following form • <Animated airline logo goes here> • <Material introducing available flights here > • From <city> to <city> departing at <time> and arriving at <time>. • <Animated logo of the Intergalactic Reservation Service goes here> • Application 2: List bookings already made in following form • <Animated logo of the Intergalactic Reservation Service goes here > • <Material introducing instructions to the traveler goes here > • Please arrive at <time> at <city> airport for your flight. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  35. Namespaces Across Multiple Components (Logical) Namespace organization (Physical) File organization (3 files) Airlines namespace Source file name: AvailabilityComponentSource.cs Availability namespace Namespace stated: Airlines.Availability Classes: Logo, AvailabilityAnnouncement Logo Component name: availability.dll AvailabilityAnnouncement Source file name: ItineraryLogoComponentSource.cs Itinerary namespace Namespace stated: Airlines.Itinerary Class: Logo Logo Component name: itineraryLogo.dll ItineraryAnnouncement Source file name: ItineraryAnnouncement.cs Namespace stated: Airlines.Itinerary Class: ItineraryAnnouncement Component name: itineraryAnnouncmnt.dll Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  36. Airline Reservation System Display Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  37. Public Key Cryptography • Any message encoded with one key can be decoded with the other. • One can’t encrypt and decrypt a message with the same key. • It’s practically impossible to deduce one key from the other. • It’s very unlikely that an encoded document can be decoded with an unmatched key Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  38. Public Key Encryption Used in .NET Public key: …iemhdZX… Private key: …92JiuHKM3… (secret) myKeys.snk use private key Hashed version Encoded version hash AssemblyInfo.cs Names & contents of assembly Assembly source Manifest assembly Verification process OK / not OK Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  39. Key Concept: Component Identity To ensure that the component we are using is the one intended, we use relatively or globally unique names: .NET also applies tamper-proofing via public key encryption. Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

  40. Summary • Microsoft “assembly” == component • Microsoft distributes computing among desktops and servers via, in part, .NET assemblies • .NET assemblies supercede and are more versatile than (D)COM(+) objects. • Exist in Intermediate Language • Permit versioning • Include “attribute” feature • Identity technique for shared assemblies reduces “dll hell” • C# language designed for .NET • Assemblies constructed via C#, VB, ... are interoperable Adapted from Software Design: From Programming to Architecture by Eric J. Braude (Wiley 2003), with permission.

More Related