23.1. The .NET Assembly

An assembly is a reusable, self-describing, versionable deployment unit for types and resources. Because it is self-describing, it allows the .NET runtime to fully understand the application and enforce dependency and versioning rules. Unlike Java—in which both a stand-alone application and a component library are deployed as a .jar file—assemblies come in four types or formats:

  1. exe. A console executable. The application must contain one entry point defined in the Main method.

  2. Library. A library (DLL) that can be used by other assemblies.

  3. Module. A nonexecutable collection of compiled code for use in other assemblies.

  4. winexe. A graphical Windows executable. The assembly must contain one entry point.

An assembly consists of the following components:

  • A manifest that contains the assembly metadata

  • One or more modules

  • Resource files, such as icons for Windows applications

Let's explore each of these in detail.

23.1.1. The Assembly Manifest

The assembly manifest consists of metadata describing the assembly and the types inside the assembly. The manifest is automatically created when the compiler creates an assembly.

A manifest consists of the following components:

  • Information about the name, version, culture, and strong name, as well as general descriptive information (company name, product name, description, and copyright). The culture information indicates the language supported by the assembly. The version information consists of the major, minor, build, and revision numbers that the runtime uses to enforce versioning policy. The strong name is a globally unique name tag given to an assembly so that it can be identified in a shared context. The general descriptive information regarding copyright, product, and company name can easily be changed by the end user (shown later).

  • A list of compiled code files that make up the assembly.

  • Information about the types exported by the assembly and references to any other assemblies that are required to support the types of this assembly.

Microsoft Intermediate Language (MSIL) code in a portable executable (PE) file will not be executed if it does not have an associated assembly manifest.

23.1.2. Modules

Often, a complex application can consist of components written in different languages. Modules are designed to hold disparate components so that they can be developed in parallel in totally different languages and later integrated into one assembly. Modules contain one or more .NET types. Modules can contain types from more than one namespace, and modules can be compiled from one or more source files.

23.1.3. Resources

Resources let you separate text and images (static content for those working with Web applications) from the application logic, thereby simplifying the maintenance of the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.244.66