One type of programme file is the DLL, or Dynamic Link Library, which stores code that can be used by other programmes. In this way, several applications can use the features contained in a single file simultaneously. Files with the DLL extension are not executable in and of themselves, unlike their EXE counterparts. Instead, they must be referenced from within other programmes. Some DLLs may even have the.EXE file extension because of their similarity to EXEs. Some Dynamic Link Libraries use the.OCX,.CPL, or.DRV file extension in addition to the more common.DLL.
In this 'C# Assembly' tutorial, you will learn the major technical aspects of Assemblies and the fundamentals involving ‘.dll’ files and ‘.exe’ files.
What Is C# Assembly?
An assembly is a unified set of capabilities formed by combining types and resources. Assembly can refer to either a dynamic link library (DLL) or an executable file (.exe), depending on its intended use. Implementation, versioning, repurposing, installation scoping, and privacy authorizations are all handled primarily through assemblies in “.NET-based applications”.
Information about an assembly can be retrieved programmatically using reflection. Assembly files contain the data that the common language runtime needs to understand how various types are implemented. According to the runtime, a type only exists within the scope of an assembly.
Content of C# Assembly
There is seven content of the C# Assembly in the .NET Framework.
All information about subassemblies that make up the assembly itself is recorded in the manifest. Metadata describes the information included in the manifest.
It's useful for the scope of visibility and version control.
The assembly's version number is part of its unique identifier.
Methods, classes, properties, events, and attributes have distinct remits and boundaries specified by their types.
Information on language and culture is defined.
The hash encoded with the public key is being used as a check for compatibility and safety.
The permissions within the assembly determine the privileges that can be granted for all aspects of the assembly's content.
Now let's discuss the Assembly Cache.
What Is an Assembly Cache?
When you set up the .NET framework, you make a repository available. This storage space has been dubbed the Assembly Cache.
The cache has both local and network components. The global cache is where all of the shared assemblies live. Data that should be kept secret for the sake of security might be found in the private folder. Your application's private cache is also where it stores any files it downloads while running.
There must be unique namespaces for all assemblies in the shared global cache. The assembly's unique identity is encoded in the folder names. Locate the Assembly Cache in the assembly folder of your Windows directory.
Types of C# Assembly
There are two types of assemblies in the .Net framework
- Process assembly: Process assembly has .exe files
- Library assembly: Library assembly has .dll files.
Library assembly is again defined in two Types -
- Private Assembly
- Shared or Public Assembly
Now let's discuss them in detail. Let's start with the Private Assembly.
To use a private assembly's features and power, a copy of the assembly must be placed in each application folder in which it is used. When we only want to share a private assembly with other applications, we only need to copy the files into the BIN folder.
So far, you have learned about the Private Assembly. Now Let’s discuss the shared Assembly.
Shared Assembly can also be referred to as "Public Assemblies." It is unnecessary to make a second copy of the assembly for use within the application itself; instead, keep the original within the system folder. In other words, you can skip copying into each individual application folder.
So far, you have learned about the Private and Shared Assembly. Now Let’s discuss Global Assembly Cache.
Global Assembly Cache
When an assembly is needed for more than one project or application, we must create it with a strong moniker and keep it in GAC or the Assembly folder by installing it with the GACUtil command.
Implementation of C# Assembly
Let's create a private assembly.
We will create a new project class library.
Let's name it PrivateAssembly
Let's choose .net core 3,1 and hit create.
Now let's write some code.
public class PrivateAssembly
public int Add(int n1, int n2)
int res = n1 + n2;
public int diff(int n1, int n2)
int res = n1 - n2;
Now let's add a new asp.net web application project in this.
We will choose asp.net web application
Let's Name it PrivateAssemblyWebform.
We will select web form as we are creating a webform and hit create
Then we will just build both projects.
Now let's build the private assembly project. We will select and add a reference to private assembly for this web application.
We will go into the project category and select the “PrivateAssembly”.
Now let's check the bin folder in the web forms directory. And here, we have our private assembly.
By now, you must have a good knowledge and command of the technical aspects of C# Assembly.
If you're eager to gain the skills required to work in a challenging, rewarding, and dynamic IT role - we've got your back! Discover the endless opportunities through this innovative Post Graduate Program in Full Stack Web Development course designed by our partners at Caltech CTME. Enroll today!
The next lesson in your C# training can be "C# Reflection". A computer program can improve its performance by reflecting on its actions and source code. Reflection in C#, for instance, lets you inspect and change runtime data about your program, which has enormous potential but which you may not yet appreciate. C# reflection's features, also known simply as "reflection," are incredibly robust and deceptively easy to use.
Simplilearn is the world's most popular online Bootcamp for learning digital economy skills, and it's here to help you do that. Digital marketing and data science are just a few subjects you will cover in-depth in the online courses.
You've come to the right place if you're interested in learning more about software development and working in the field. The Caltech CTME and the Indian Institute of Technology, Kanpur, have collaborated with Simplilearn to deliver their Software Development courses. In addition to more advanced topics like Competitive Programming, these courses teach the fundamentals of data structures and algorithms. As a software developer, data structures, including trees, graphs, and queues, will be taught to you.
The comments section below is open to questions and comments about this 'C# Assembly' tutorial. Happy learning!