Following are the different parts of assembly:
- Manifest: It has the information about the version of the assembly.
- Type Metadata: Contains the binary information of the program
- MSIL: Microsoft Intermediate Language Code
- Resources: List of related files
In a .NET interview, when asked to explain the different parts of an assembly, you would typically cover the following components:
- Manifest: The manifest is a metadata component within an assembly that contains information about the assembly itself. It includes details such as the assembly’s identity, versioning information, culture, strong name (if signed), and a list of all the files that make up the assembly.
- Metadata: Metadata is data that describes the types, members, and references within the assembly. It includes information such as the names, data types, and access modifiers of classes, interfaces, methods, properties, fields, and events within the assembly. Metadata is used extensively by the Common Language Runtime (CLR) for various purposes, including type resolution, validation, and execution.
- IL Code (Intermediate Language): When you compile a .NET application, the source code is translated into IL code, also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). IL is a platform-independent, low-level programming language that serves as an intermediate representation of the source code. IL code is stored within the assembly and is executed by the CLR during runtime. It allows .NET applications to be portable across different architectures and operating systems.
- Resources: Assemblies can contain resources such as images, icons, strings, and other non-executable data. These resources are embedded within the assembly and can be accessed programmatically at runtime using APIs provided by the .NET Framework.
- Type Metadata: Type metadata contains information about the types (classes, interfaces, structs, enums, delegates) defined within the assembly, including their members and relationships with other types. This metadata is used by the CLR for type safety, reflection, and other runtime operations.
- References: Assemblies can reference other assemblies, either explicitly or implicitly, to utilize types and functionality defined in those assemblies. References can be specified at compile time or dynamically loaded at runtime using mechanisms such as reflection or assembly probing.
- Security Information: Assemblies can include security-related information such as permissions, code access security (CAS) settings, and digital signatures. This information is used by the CLR to enforce security policies and ensure the integrity and authenticity of the assembly.
- Execution Context: The assembly also defines the execution context for the code it contains. This includes settings such as the entry point (for executable assemblies), execution environment (e.g., CLR version, runtime host), and application domain (for managing isolation and security boundaries).
Explaining these components demonstrates a comprehensive understanding of how assemblies work in the .NET Framework and CLR environment.