Javatpoint Logo
Javatpoint Logo

Type of Assembly in C#

Introduction:

Assembly is an important concept in C#. It is a collection of code files that are compiled into an executable or a Dynamic Link Library (DLL). Depending on their location and intended use, assemblies can be divided into many categories. We will examine the various assembly types in C# in this article.

Private Assemblies:

An Assembly that is solely used by one application is referred to as a Private Assembly. It is typically found in the directory for the application or a subdirectory of the directory for the programme. Private Assemblies are not intended to be shared with other applications. They are used to store application-specific code and resources.

Private Assemblies are created when an application is compiled. When an application is compiled, all the code files and resources that are used by the application are compiled into a single assembly.The application's directory or a subdirectory of the application's directory will thereafter contain this assembly.

Private Assemblies are simple to deploy and use. They don't need any extra installation or setting. They are automatically loaded by the .NET runtime when the application starts.

Shared Assemblies:

An assembly that is used by several programmes is referred to as a shared assembly. It is typically found in the Global Assembly Cache (GAC) or a common directory. Multiple applications are supposed to share a shared assembly. They are used to store resources and code that are shared by various applications.

Shared Assemblies are created using the strong name tool (sn.exe). A digital signature for the assembly is applied using the strong name tool. The digital signature guarantees that the assembly is genuine and unaltered.

The Global Assembly Cache (GAC) houses shared assemblies. Shared assemblies are kept in the GAC, which serves as a central repository. The GAC location is in the Windows directory (C:\Windows\assembly). Shared assemblies are registered with the GAC using the gacutil.exe tool.

Shared assemblies require special configuration and installation. They cannot be simply copied to the application's directory. They need to be registered with the GAC using the gacutil.exe tool.

Satellite Assemblies:

An assembly used to store regional resources is referred to as a Satellite Assembly. It is typically found in a subdirectory of the directory for the application or a subdirectory of the directory for the Shared Assembly. Localized resources like strings, pictures, and audio files are kept in satellite assemblies.

Satellite Assemblies are created using the resgen.exe tool. The resgen.exe tool is used to create a resource file (.resx) from a text file. The resource file is then compiled into a satellite assembly using the al.exe tool.

Satellite Assemblies are named using a specific naming convention. The naming convention for satellite assemblies is as follows:

The <AssemblyName> part of the name is the name of the main assembly that the satellite assembly is associated with. The.NET runtime automatically loads satellite assemblies when the application first launches. The .NET runtime automatically selects the appropriate satellite assembly based on the user's culture settings.

Dynamic Link Libraries (DLLs):

A Dynamic Link Library (DLL) is a type of assembly that contains code that can be used by multiple applications. Similar to shared assemblies, DLLs are created with the intention of being used by numerous applications. DLLs, however, differ from shared assemblies in that they do not have a distinctive name.

DLLs are kept in the directory of the application or a subdirectory of the directory of the application. They can be used by multiple applications by simply copying the DLL to the application's directory.

DLLs are created using the same tools that are used to create shared assemblies. However, DLLs do not require a strong name. They can be signed with a digital signature, but this is optional.

Conclusion:

Assemblies are an important part of the .NET framework and are used to store code files and resources that can be used by one or more applications. There are four main types of assemblies in C#: Private Assemblies, Shared Assemblies, Satellite Assemblies, and Dynamic Link Libraries (DLLs). Each type of assembly has its own purpose and usage.

Application-specific code and resources that are only needed by a single application are kept in private assemblies. They don't need any extra installation or configuration and are simple to deploy. They are automatically loaded by the .NET runtime when the application starts.


Next TopicUnity Container C#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA