What is Assemblies in .NET Framework?
An assembly is the actual .dll file on your hard drive where the classes of the .NET Framework are stored
.
For example, all the classes contained in the ASP.NET Framework are located in an assembly named System.Web.dll.
.
More accurately, an assembly is the primary unit of deployment, security, and version control in the .NET Framework. Because an assembly can span multiple files, an assembly is often referred to as a "logical" dll
.
There are two types of assemblies:
.
Private Assemblies: - A private assembly can be used by only a single application
.
Shared Assemblies: - A shared assembly, can be used by all applications located on the same server
.
Shared assemblies are located in the Global Assembly Cache (GAC).
.
For example, the System.Web.dll assembly and all the other assemblies included with the .NET Framework are located in the Global Assembly Cache.
.
To use any particular class in the .NET Framework, you must do two things. First, your application must reference the assembly that contains the class. Second, your application must import the namespace associated with the class
.
In most cases, you won't worry about referencing the necessary assembly because the most common assemblies are referenced automatically
.
However, if you need to use a specialized assembly, you need to add a reference explicitly to the assembly
.
For example, if you need to interact with Active Directory by using the classes in the System.DirectoryServices namespace, then you will need to add a reference to the System.DirectoryServices.dll assembly to your application
.
We can add a reference to an assembly in ASP.NET applications explicitly by selecting the menu option Web Site, Add Reference, and selecting the name of the assembly that you need to reference
.
For example, adding a reference to the System.Messaging.dll assembly reflects following changes in the web configuration file of ASP.NET application
.
<Configuration>
<system.web>
<Compilation>
<Assemblies>
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
</system.web>
</configuration>