Menu
What are .NET Assemblies? I browsed over the net and I am not able to understand the definition.
John
18 Answers
In more simple terms: A chunk of (precompiled) code that can be executed by the .NET runtime environment. A .NET program consists of one or more assemblies.
Assembly language instructions access values in memory by considering a register’s contents to be a memory address, and then dereferencing it the same way you would use a pointer in a C program. In fact, to me C and assembly language seem very similar in this way, which I suspect is not a coincidence. An Assembly is a basic unit of application deployment and versioning. An Assembly is also called the building block of a.Net application. An Assembly is either a.exe or.dll file. An Assembly structure consists of the following parts: Assembly manifest (name,language,version). CIL code (logic part). Type information (Datatype).
Adrian GrigoreAdrian Grigore23.7k2929 gold badges120120 silver badges202202 bronze badges
Assembly is the smallest unit of deployment of a .net application.It can be a dll or an exe.
There are mainly two types to it:
There are mainly two types to it:
- Private Assembly:The dll or exe which is sole property of one application only. It is generally stored in application root folder
- Public/Shared assembly:It is a dll which can be used by multiple applications at a time. A shared assembly is stored in GAC i.e Global Assembly Cache.
Sounds difficult? Naa....
GAC is simply C:WindowsAssembly folder where you can find the public assemblies/dlls of all the softwares installed in your PC.
GAC is simply C:WindowsAssembly folder where you can find the public assemblies/dlls of all the softwares installed in your PC.
There is also a third and least known type of an assembly: Satellite Assembly.
A Satellite Assembly contains only static objects like images and other non-executable files required by the application.
A Satellite Assembly contains only static objects like images and other non-executable files required by the application.
Hope this helps the readers!
Şafak Gür3,57033 gold badges4141 silver badges7878 bronze badges
mangeshktmangeshkt2,77111 gold badge1313 silver badges88 bronze badges
Assemblies
When you compile an application, the MSIL code created is stored in an assembly . Assemblies includeboth executable application files that you can run directly from Windows without the need for any otherprograms (these have a .exe file extension), and libraries (which have a .dll extension) for use by otherapplications.
In addition to containing MSIL, assemblies also include meta information (that is, information about theinformation contained in the assembly, also known as metadata ) and optional resources (additional dataused by the MSIL, such as sound files and pictures). The meta information enables assemblies to be fullyself - descriptive. You need no other information to use an assembly, meaning you avoid situations suchas failing to add required data to the system registry and so on, which was often a problem whendeveloping with other platforms.
This means that deploying applications is often as simple as copying the files into a directory on aremote computer. Because no additional information is required on the target systems, you can just runan executable file from this directory and (assuming the .NET CLR is installed) you ’ re good to go.
Of course, you won ’ t necessarily want to include everything required to run an application in one place.You might write some code that performs tasks required by multiple applications. In situations like that,it is often useful to place the reusable code in a place accessible to all applications. In the .NETFramework, this is the Global Assembly Cache (GAC) . Placing code in the GAC is simple — you just placethe assembly containing the code in the directory containing this cache.
SalehSaleh1,9551010 gold badges3737 silver badges6767 bronze badges
An assembly is the actual .dll file on your hard drive where the classes in 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.
Note
The .NET Framework (version 2.0) includes 51 assemblies.
There are two types of assemblies: private and shared. A private assembly can be used by only a single application. A shared assembly, on the other hand, 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.
Note
The Global Assembly Cache is located physically in your computer's WINDOWSAssembly folder. There is a separate copy of every assembly in your WINDOWSMicrosoft.NETFrameworkv2.0.50727 folder. The first set of assemblies is used at runtime and the second set is used at compile time.
Before you can use a class contained in an assembly in your application, you must add a reference to the assembly. By default, an ASP.NET application references the most common assemblies contained in the Global Assembly Cache:
mscorlib.dll
System.dll
System.Configuration.dll
System.Web.dll
System.Data.dll
System.Web.Services.dll
System.Xml.dll
System.Drawing.dll
System.EnterpriseServices.dll
System.Web.Mobile.dll
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.
Each class entry in the .NET Framework SDK documentation lists the assembly and namespace associated with the class. For example, if you look up the MessageQueue class in the documentation, you'll discover that this class is located in the System.Messaging namespace located in the System.Messaging.dll assembly.
If you are using Visual Web Developer, you can add a reference to an assembly explicitly by selecting the menu option Website, 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 results in the web configuration file in Listing 1.4 being added to your application.
Eg. Web.Config
If you prefer not to use Visual Web Developer, then you can add the reference to the System.Messaging.dll assembly by creating the file in the above example by hand
Hung VuHung Vu
Wikipedia has to say:
In the Microsoft .NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security. There are two types: process assemblies (EXE) and library assemblies (DLL). A process assembly represents a process which will use classes defined in library assemblies. .NET assemblies contain code in CIL, which is usually generated from a CLI language, and then compiled into machine language at runtime by the CLR just-in-time compiler. An assembly can consist of one or more files. Code files are called modules. An assembly can contain more than one code module and since it is possible to use different languages to create code modules it is technically possible to use several different languages to create an assembly. Visual Studio however does not support using different languages in one assembly.
If you really did browse it would help if you'd clarify what you don't understand
Christina MayersChristina Mayers
See this:
![Assembly In C# Assembly In C#](/uploads/1/2/4/8/124895491/410313568.png)
In the Microsoft .NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security
Anton GogolevAnton Gogolev93.2k3232 gold badges182182 silver badges269269 bronze badges
physical collection of Class, interface, enum etc which is in IL code. Which can be .EXE or .DLL file .EXE is executable file and .DLL can dynamically used in any .net Supported language.
Govind KamalaPrakash MalviyaGovind KamalaPrakash Malviya9,6181414 gold badges5858 silver badges8585 bronze badges
An assembly is a runtime unit consisting of types and other resources. All types in an assembly have the same version number.
Often, one assembly has only one namespace and is used by one program. But it can span over several namespaces. Also, one namespace can spread over several assemblies. In large designs, an assembly may consist of multiple files that are held together by a manifest (i.e. a table of contents).
In C#, an assembly is the smallest deployment of a .Net application.It can be a dll or an exe.It has two types : 1. Private Assembly 2. Public/Shared Assembly
Abhishek SinghAbhishek Singh
MSDN has a good explanation:
Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.
Matt WarrenMatt Warren8,64166 gold badges4141 silver badges6161 bronze badges
In addition to the accepted answer, I want to give you an example!
For instance, we all use
But Where is the code for System.Console.WriteLine!?
which is the code that actually puts the text on the console?
which is the code that actually puts the text on the console?
If you look at the first page of the documentation for the Console class, you‘ll see near the top the following: Assembly: mscorlib (in mscorlib.dll)This indicates that the code for the Console class is located in an assem-bly named mscorlib. An assembly can consist of multiple files, but in this case it‘s only one file, which is the dynamic link library mscorlib.dll.
The mscorlib.dll file is very important in .NET, It is the main DLL for class libraries in .NET, and it contains all the basic .NET classes and structures.
if you know C or C++, generally you need a #include directive at the top that references a header file. The include file provides function prototypes to the compiler. on the contrast The C# compiler does not need header files. During compilation, the C# compiler access the mscorlib.dll file directly and obtains information from metadata in that file concerning all the classes and other types defined therein.
The C# compiler is able to establish that mscorlib.dll does indeed contain a class named Console in a namespace named System with a method named WriteLine that accepts a single argument of type string.
The C# compiler can determine that the WriteLine call is valid, and the compiler establishes a reference to the mscorlib assembly in the executable.
by default The C# compiler will access mscorlib.dll, but for other DLLs, you‘ll need to tell the compiler the assembly in which the classes are located. These are known as references.
I hope that it's clear now!
From DotNetBookZero Charles pitzold
Ahmed KhaShabaAhmed KhaShaba
An assembly is a collection of types and resources that forms a logical unit of functionality. All types in the .NET Framework must exist in assemblies; the common language runtime does not support types outside of assemblies. Each time you create a Microsoft Windows® Application, Windows Service, Class Library, or other application with Visual Basic .NET, you're building a single assembly. Each assembly is stored as an .exe or .dll file.
Source : https://msdn.microsoft.com/en-us/library/ms973231.aspx#assenamesp_topic4
For those with Java background like me hope following diagram clarifies concepts -
Assemblies are just like jar files (containing multiple .class files). Your code can reference an existing assemblie or you code itself can be published as an assemblie for other code to reference and use (you can think this as jar files in Java that you can add in your project dependencies).
At the end of the day an assembly is a compiled code that can be run on any operating system with CLR installed. This is same as saying .class file or bundled jar can run on any machine with JVM installed.
Aniket ThakurAniket Thakur44.3k2828 gold badges201201 silver badges223223 bronze badges
In .Net, an assembly can be:
![Http://assemblersinc.com Http://assemblersinc.com](/uploads/1/2/4/8/124895491/922245194.png)
A collection of various manageable parts containing
VS1VS1Types (or Classes)
, Resources (Bitmaps/Images/Strings/Files)
, Namespaces
, Config Files
compiled Privately
or Publicly
; deployed to a local
or Shared (GAC)
folder; discover-able
by other programs/assemblies
and; can be version-ed.6,05533 gold badges2828 silver badges5454 bronze badges
As assembly is the smallest unit of versioning security, deployment and reusability of code in Microsoft.Net.
It contains:
Lay LeangsrosLay Leangsros6,09644 gold badges2323 silver badges3434 bronze badges
Assembly is the fundamental part of programming with .NET Framework.It contain code that CLR executes MSIL(Microsoft Intermediate Language) code in a portable executable file will not be executed if it does not have an associated assembly manifest.
Kamini joshiKamini joshi
.NET applications are constructed by piecing together any number of assemblies. Simply put, an assembly is nothing more than a versioned, self-describing binary (DLL or EXE) containing some collection of types (classes, interfaces, structures, etc.) and optional recourses (images, string tables and whatnot). One thing to be painfully aware of right now, is that the internal organization of a .NET assembly is nothing like the internal organization of a classic COM server (regardless of the shared file extensions).
Shivam SharmaShivam Sharma12511 gold badge44 silver badges1212 bronze badges
In .NET, when we compile our source code then assembly gets generated in Visual Studio. Assembly consists of two parts Manifest and IL(Intermediate Language). Manifest contains assembly metadata means assembly's version requirements, security identity, names and hashes of all files that make up the assembly. IL contains information about classes, constructors, main method etc.
GaganGagan
I found this link to be very helpful. It even gives you a glimpse of how IL plays a role in .NET.
BrandonBrandon
Visual Studio solutions consists of one or more projects. For Example : Console projects can produce an assembly. An assembly is logically chunk of code that can be shipped to customers, and physically an .EXE (executable program) or .DLL (are reusable by other programs).
Eldiyar TalantbekEldiyar Talantbek
protected by Community♦Oct 21 '16 at 6:58
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?