1 / 24

Understanding Code Compilation and Deployment

Understanding Code Compilation and Deployment. Lesson 4. Objective Domain Matrix. Understanding Code Compilation. Code written in high-level programming language must be translated to the machine language before it can be executed . Traditional compilation model:. .NET Compilation Model.

kyoko
Download Presentation

Understanding Code Compilation and Deployment

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. Understanding Code Compilation and Deployment Lesson 4

  2. Objective Domain Matrix

  3. Understanding Code Compilation • Code written in high-level programming language must be translated to the machine language before it can be executed. • Traditional compilation model:

  4. .NET Compilation Model • In the .NET Framework, compilation is a two-step process: • CIL: Common Intermediate Language • The Common Language Runtime (CLR) uses Just-in-Time (JIT) compilation to convert the CIL code into machine code.

  5. Common Language Infrastructure (CLI) • CLI is an international standard that provides the specifications for the executable code and the runtime environment in which the code runs. • CLI makes it easier to write components and applications in any language. • The Common Language Runtime (CLR) is Microsoft’s implementation of the CLI.

  6. CLI Specifications - 1 • Common Type System (CTS) – Specifies rules that allows for objects written in one language to be used by objects written in another language as if they were written in the same language. • Common Language Specification (CLS) – Specifies rules that a language must comply with in order to interoperate with other CLS-compliant programming languages.

  7. CLI Specifications - 2 • Metadata - A structured way to represent information about a program structure that the CLI uses to locate and load classes at runtime. • Virtual Execution System (VES) - Specifies how the runtime loads and executes CLI-compatible programs.

  8. Language Interoperability • Language interoperability means that code written in one programming language can be fully used by code written in a different programming language. • CLS specifies a set of rules that enables the code written in a programming language to interoperate with the code written in other programming languages on the .NET Framework.

  9. Assembly • An assembly is a collection of types and resources that is built to work together to form a logical unit of functionality. • Assemblies are the fundamental unit of deployment, version control, and security in the .NET Framework. • The output from .NET language compiler (a .dll file or an .exe file) is bundled into an assembly.

  10. Assembly Structure • An assembly contains the following four pieces of information: • Assembly manifest contains information such as version and identity of the assembly. • Metadata related to the classes contained in the assembly • CIL code that implements the classes • A set of resources (such as .bmp file or a .jpg file) used by the classes.

  11. Assembly Metadata • Metadata is the data that describes the types defined by the code and the external types used by the code. • Metadata has complete information about the structure of a type and its members. • Metadata is independent of any particular programming language and is stored along with the CIL as part of an assembly.

  12. IL Disassembler (ildasm.exe) • Allows you to view the contents of an assembly like the manifest, metadata and the CIL.

  13. Assembly Deployment • Assemblies can be deployed as: • Private assemblies • Shared assemblies • A private assembly is designed to be used by only a single application. • A shared assembly is designed to be used by multiple applications.

  14. Private Assemblies • A private assembly is local to the application that uses it and is deployed within the application’s directory structure. • Any changes to a private assembly cannot possibly affect any other installed application on the same machine. • The .NET Framework does not impose any special versioning or naming requirements for a private assembly.

  15. Shared Assemblies • The shared assemblies are all installed at a common, well-known location on the file system known as the Global Assembly Cache (GAC). • The .NET Framework allows multiple versions of a shared assembly to coexist. • A shared assembly must have an associated strong name.

  16. Strong Naming • Strong name specifies an assembly’s unique identity. • Strong name uses four attributes to identify an assembly: • Simple name • Version number • Culture identity (optional) • Public key token

  17. Strong Name Tool • The Strong Name tool helps sign assemblies with strong names. • The strong name tool is used to generate keys used for creating strong names.

  18. Signing the Assembly • The Signing tab in the Visual Studio project’s properties dialog box allows you to assign a strong name to the assembly.

  19. Assembly Information • The Assembly Information dialog box allows you to specify version and other information.

  20. Global Assembly Cache • The Global Assembly Cache (GAC) is the central repository for storing shared assemblies on a computer. • Ways to add an assembly to the GAC: • Windows Installer: Recommended approach for installing assemblies on the end user’s computer. • Global Assembly Cache tool (gacutil.exe): Recommended only for development and testing.

  21. Global Assembly Cache Benefits • Integrity check: This check guarantees that the contents of the assembly have not been changed since it was built. • Security: Only users with administrator privileges can modify GAC contents. • Side-by-side versioning: Multiple assemblies with the same name but different version numbers can be maintained in the GAC.

  22. Using the Global Assembly Cache Tool • Install assembly to the GAC • gacutil /i assemblyFileName • Uninstall assembly from GAC • gacutil/u assemblyName • List all versions of an assembly from GAC • gacutil /l assemblyName

  23. Assembly Versioning • Side-by-side execution: Some applications still use the old version of the assembly while other applications use the new version. • Publisher Policy (bug-fix update): All applications that reference the defective version of the assembly to start using the new version—and preferably without any modifications to the already installed applications.

  24. Recap • Understanding code compilation • .NET Compilation Model • Common Language Infrastructure (CLI) • Language interoperability • Assembly • Assembly Metadata • IL Disassembler • Private Assembly • Shared Assembly • Strong Name • Strong Name Tool • Global Assembly cache • Global Assembly Cache Tool (gacutil.exe) • Version control

More Related