Assemblies in .Net

When we create a project in Visual Studio .Net and compile it, assemblies are created. These assemblies are the fundamental units of applications in the .NET Framework. An assembly can contain classes, structures, interfaces, and resources that an application requires.

When we compile a program, the compiler translates the source code into the Intermediate Language code (IL). In addition to translating the code into IL, the compiler also produces metadata about the program during the process of the compilation. Metadata contains the description of the program, such as the classes and interfaces, the dependencies, and the versions of the components used in the program.

The IL and the metadata are linked in an assembly.

An IL and metadata exist in portable executable file(EXE/DLL).

If we look at any project folder, we will find a bin folder that contains, say myproject.dll/ myproject.exe and myproject.pdb files. The myproject.dll/ myproject.exe is the assembly, and myproject.pdb ( program database ) file contains debugging information for the assembly. The .pdb file also contains information the linker can use when debugging the assembly.

So, when we create and compile the project in VS.Net, the assembly is automatically generated and copied into the application's bin directory. An assembly also contains an assembly manifest that contains the assembly metadata. This metadata contains information about the assembly version, its security identity, the resources required by the assembly and the scope of the assembly. This information is stored within the assembly file (DLL/EXE) itself. Note that the assembly contains two types of metadata. One, is the type metadata and the other is the assembly metadata.

Process assemblies (EXE) and library assemblies (DLL)

A process assembly represents a process which uses classes defined in library assemblies. The compiler will have a switch to determine if the assembly is a process or a library and will set a flag in the PE file. .NET does not use the extension to determine if the file is a process or library. This means that a library may have either .dll or .exe as its extension.

The .Net CLR while executing looks for the metadata in order to locate and load classes, as well as generate native code and security.

Note that the assembly metadata is assembly manifest and it simplifies the deployment model. Because it contains so much information about the assembly, you can simply XCOPY the assembly onto another computer, along with its related manifest.

Why use Assemblies?

The goal of the assembly model is the elimination of DLL Hell. Under the current COM/COM+ model, a catalog of DLLs is centralized in the Windows Registry. When a new version of a DLL is published, the registry re-references the catalog to point to the new DLL. This centralized registration paradigm makes it challenging for multiple applications to depend on the same DLL. Most often, the application binds to a DLL in a centralized location, rather than run multiple versions of a component by using side-by-side execution.

The .NET Framework makes it easy to run multiple versions of a component because it stores assemblies in local application directories by default. This isolates the assembly from use by any other application and protects the assembly from system changes.

Types of Assemblies

Assemblies can be private or shared. The assembly which is used by a single application is called as private assembly. Suppose we have created a DLL which encapsulates business logic. This DLL is used by the client application only and not by any other application. In order to run the application properly the DLL must reside in the same folder in which the client application is installed. Thus the assembly is private to the application.

Suppose we are creating a general purpose DLL which provides functionality to be used by a variety of applications. Now, instead of each client application having its own copy of DLL we can place the DLL in 'global assembly cache'. Such assemblies are called as shared assemblies.

When we create an application in Visual Studio.Net that uses a component, which is not in the GAC, the assembly is automatically copied to the project´s bin folder. So, if we simply the copy the project´s bin folder, the assembly for the component is copied as well. Since the files the application needs are in the same folder, the application can run without registration.

Benefits of Private Assemblies

Private assemblies are installed in a directory named bin located under the application directory. These files are private to the application.

No versioning is required, as long as it is the same version as the one with which the application was built.
It enables XCOPY deployment
There is no configuration or signing
It is great for small utility Assemblies/ application specific code.


When you have multiple applications using one assembly, you have to deploy the assembly to the bin directory of each application.

How to create an Assembly

A shared assembly can be created in Visual Studio.Net by generating Cryptographic Key Pair using the tool SN.exe utility. The sn.exe utility is located in the Bin directory. After creating the shared assembly we should sign the shared assembly to the GAC by using Gacutil tool. More about creating a shared assembly.

What is Global Assembly Cache?

An assembly that is shared by multiple applications is called a global assembly and is installed in the global assembly cache (GAC).

Global assembly cache is nothing but a special disk folder where all the shared assemblies are kept. It is located under <drive>:\Windows\Assembly folder on every machine running the .NET framework.

GAC acts as a central location for assemblies that is accessible by any application.


  1. Assembly physically exist as DLLs or EXEs.
  2. An assembly consists of a manifest and the portable executables (PE).
  3. Global assembly cache is nothing but a special disk folder where all the shared assemblies will be kept.

A different perspective on .NET Assembly - What is .NET Assembly?

cover image of azure cloud book

Develop Azure Applications

Azure Cloud is gaining popularity and is competing with Amazon Elastic Cloud and Google Cloud for a spot in the billion dollar Cloud computing space.

With this book learn how to use - Table (an Azure Table is different from a SQL Server Table), Queue, Blob storage services, use your local machine to create an Application and a Service, how Azure splits a Table to achieve Load Balancing, Scalability based on the Partition Key, AppFabric Service Bus, Access Control Service, role of Fabric Controller, features of Azure SQL Database and Content Delivery Network.

Many have mastered Cloud Programming and are enjoying the benefits. Why not you?

View Highlights » View Contents »
cover image of foundation database programming book

Create your Own Accounting Software

A foundation book to Master Accounting Software Development, VB.Net, C# and OOPs programming. Detailed explanation of the Accounting domain for programmers is included. SQL and ADO.Net is also covered in detail.

This book gives you a strong foundation in Application Development.

A thorough understanding of the contents will enable you to grasp the topics covered in the accompanying books quite easily. This is because, the accounting domain is dealt with great detail in this book.

The ideal book to get started with application development in the .Net world.

View Highlights » View Contents »

cover image of book

Create your Own WEB ERP Software using ASP.Net

This book opens you to the Web. Using ASP.Net, C# and SQL Server as the tools, you will learn to build a Multi Tier Web Application as recommended by Microsoft. You will learn implementing inline GridView control, Transaction Management for a layered Web Application, build Data Access component and a Business Layer component.

Opens you to a world of opportunities. You will be able to develop a Web ERP application including all the five modules and learn how to use the TreeView control and GridView control to implement transactions such as Purchase Invoice, Sales Order and Sales Invoice.

View Highlights » View Contents »
cover image of entity framework book

ASP.Net MVC 5 Application Development Using Entity Framework 6 and VS 2015

Entity frameworks is the latest buzz in .Net programming and is the data access technology for Microsoft OS based hand held devices and web applications. Learn to integrate EF into an ASP.Net Application and MVC application. Create, explore and query the Entity Data Model. Learn how to use ObjectDataSource control and GridView control in an ASP.Net Application.

Also, learn to build Three-Tier ASP.Net application, create a business-class, implement methods in the class to perform CRUD operations and bind a GridView to the ObjectDataSource control. Learn how to handle concurrency and managing Transactions.

View Contents »