Type Of Assembly In C#

Introduction:

Assembly represents a crucial idea in C# programming. It comprises code files compiled into either an executable program or a Dynamic Link Library (DLL). Assemblies are categorized based on their location and purpose. This article will explore the different types of assemblies in C#.

Private Assemblies:

An Assembly that is exclusively utilized by a single application is known as a Private Assembly. Usually located within the application's directory or a subdirectory of the program's directory, Private Assemblies are not meant for sharing with other applications. They serve the purpose of housing application-specific code and resources.

Private assemblies are generated during the compilation of an application. During this process, all the code files and resources utilized by the application are combined into a unified assembly. Following the compilation, this assembly will be located in the application's directory or in one of its subdirectories.

Private Assemblies are straightforward to deploy and utilize. They do not require any additional installation or configuration. The .NET runtime automatically loads them upon application launch.

Shared Assemblies:

An assembly that multiple programs utilize is known as a shared assembly. It is commonly located in the Global Assembly Cache (GAC) or a shared directory. The purpose of a shared assembly is to facilitate resource and code sharing among different applications.

Creating Shared Assemblies involves utilizing the strong name tool (sn.exe). The strong name tool is employed to add a digital signature to the assembly. This digital signature ensures the authenticity and integrity of the assembly.

The Global Assembly Cache (GAC) stores shared assemblies, serving as a centralized repository for them. These shared assemblies are specifically placed within the GAC, which is typically located in the Windows directory at C:\Windows\assembly. To register shared assemblies with the GAC, developers utilize the gacutil.exe tool.

Shared assemblies necessitate particular setup and deployment. Merely transferring them to the application folder is insufficient. Instead, they must be formally added to the Global Assembly Cache (GAC) through the utilization of the gacutil.exe utility tool.

Satellite Assemblies:

An assembly designated for storing resources specific to a particular region is known as a Satellite Assembly. These assemblies are commonly located within a subdirectory of the application directory or a subdirectory of the Shared Assembly directory. Satellite assemblies house localized resources such as strings, images, and audio files.

Satellite Assemblies are generated with the resgen.exe utility. This tool is employed to convert a text file into a resource file (.resx). Subsequently, the resource file is compiled into a satellite assembly with the al.exe tool.

Satellite Assemblies are titled following a precise naming structure. The naming format for satellite assemblies adheres to the following pattern:

Example

<AssemblyName>.resources.dll

The initial segment of the name refers to the primary assembly linked with the satellite assembly. Upon the application's initial launch, the .NET framework autonomously loads satellite assemblies. Based on the user's cultural preferences, the .NET runtime automatically chooses the suitable satellite assembly.

Dynamic Link Libraries (DLLs):

A Dynamic Link Library (DLL) is an assembly type that holds executable code meant for utilization by multiple applications. DLLs, like shared assemblies, are designed for widespread application usage. Unlike shared assemblies, DLLs lack a unique identifier.

DLLs are typically stored in the application's directory or in a subdirectory within the application's directory. They can be shared across several applications by duplicating the DLL file into each application's directory.

Dynamic Link Libraries (DLLs) are generated using identical tools utilized for constructing shared assemblies. Nonetheless, unlike shared assemblies, DLLs do not mandate a strong name. While DLLs can be authenticated with a digital signature, this step is not compulsory.

Conclusion:

Assemblies play a crucial role within the .NET framework as containers for code files and resources accessible to multiple applications. The C# language distinguishes between four key assembly types: Private Assemblies, Shared Assemblies, Satellite Assemblies, and Dynamic Link Libraries (DLLs). Each variation serves a distinct function and is applied in specific scenarios.

Application-specific code and resources exclusive to a particular application are housed in private assemblies. These assemblies do not require additional setup or installation and are straightforward to deploy. The .NET runtime automatically loads them upon application initialization.

Input Required

This code uses input(). Please provide values below: