What is a .Net Assembly?
The .NET assembly is the standard for components developed with the Microsoft.NET. Dot NET assemblies may or may not be executable, i.e., they might exist as the executable (.exe) file or dynamic link library (DLL) file. All the .NET assemblies contain the definition of types, versioning information for the type, meta-data, and manifest. The designers of .NET have worked a lot on the component (assembly) resolution.
An assembly can be a single file or it may consist of the multiple files. In the case of multi-file, there is one master module containing the manifest while other assemblies exist as non-manifest modules. A module in .NET is a subpart of a multi-file .NET assembly. Assembly is one of the most interesting and extremely useful areas of .NET architecture along with reflections and attributes.
.NET supports three kinds of assemblies:
- private
- shared
- satellite
Private Assembly
Private assembly requires us to copy separately in all application folders where we want to use that assembly’s functionalities; without copying, we cannot access the private assembly features and power. Private assembly means every time we have one, we exclusively copy into the BIN folder of each application folder.
Public Assembly
Public assembly is not required to copy separately into all application folders. Public assembly is also called Shared Assembly. Only one copy is required in system level, there is no need to copy the assembly into the application folder.
Public assembly should install in GAC.
Shared assemblies (also called strong named assemblies) are copied to a single location (usually the Global assembly cache). For all calling assemblies within the same application, the same copy of the shared assembly is used from its original location. Hence, shared assemblies are not copied in the private folders of each calling assembly. Each shared assembly has a four-part name including its face name, version, public key token, and culture information. The public key token and version information makes it almost impossible for two different assemblies with the same name or for two similar assemblies with a different version to mix with each other.
GAC (Global Assembly Cache)
When the assembly is required for more than one project or application, we need to make the assembly with a strong name and keep it in GAC or in the Assembly folder by installing the assembly with the GACUtil command.
Satellite Assembly
Satellite assemblies are used for deploying language and culture-specific resources for an application.
Learn more here: Private, Public, and Satellite Assemblies in .NET
What are the basic components of the .NET platform?
The basic components of .NET platform (framework) are:
|
.Net Applications (Win Forms,Web Applications,Web Services) |
| Data(ADO.Net) and XML Library |
|
FrameWork Class Library(FCL)
(IO,Streams,Sockets,Security,Reflection,UI)
|
|
Common Language Runtime(CLR)
(Debugger,Type Checker,JITer,GC) |
|
Operating System (Windows,Linux,UNIX,Macintosh,etc.,) |
Common Language Runtime (CLR)
The most important part of the .NET Framework is the .Net Common Language Runtime (CLR) also called .Net Runtime in short. It is a framework layer that resides above the Operating System and handles/manages the execution of the .NET applications. Our .Net programs don't directly communicate with the Operating System but through CLR.
MSIL (Microsoft Intermediate Language) Code
When we compile our .Net Program using any .Net compliant language like (C#, VB.NET, C++.NET) it does not get converted into the executable binary code but to an intermediate code, called MSIL or IL in short, understandable by CLR. MSIL is an OS and H/w independent code. When the program needs to be executed, this MSIL or intermediate code is converted to binary executable code, called native code. The presence of IL makes it possible for the Cross-Language Relationship as all the .Net compliant languages produce the similar standard IL code.
Just In Time Compilers (JITers)
When our IL compiled code needs to be executed, CLR invokes JIT compilers which compile the IL code to native executable code (.exe or .dll) for the specific machine and OS. JITers in many ways is different from traditional compilers as they, as their name suggests, compile the IL to native code only when desired e.g., when a function is called, IL of function's body is converted to native code; just in time of need. So, the part of code that is not used by a particular run is not converted to native code. If some IL code is converted to native code then the next time when it's needed to be used, the CLR uses the same copy without re-compiling. So, if a program runs for some time, then it won't have any just in a time performance penalty. As JITers are aware of processor and OS exactly at runtime, they can optimize the code extremely efficiently resulting in very robust applications. Also, since JITer knows the exact current state of executable code, they can also optimize the code by in-lining small function calls (like replacing body of small function when its called in a loop, saving the function call time). Although Microsoft stated that C# and .Net are not competing with languages like C++ in efficiency, speed of execution, JITers can make your code even faster than C++ code in some cases when the program is run over an extended period of time (like web-servers).
Framework Class Library (FCL)
.NET Framework provides a huge set of Framework (or Base) Class Library (FCL) for common, usual tasks. FCL contains thousands of classes to provide them access to Windows API and common functions like String Manipulation, Common Data Structures, IO, Streams, Threads, Security, Network Programming, Windows Programming, Web Programming, Data Access, etc. It is simply the largest standard library ever shipped with any development environment or programming language. The best part of this library is they follow extremely efficient OO design (design patterns) making their access and use very simple and predictable. You can use the classes in FCL in your program just as you use any other class and can even apply inheritance and polymorphism on these.
Common Language Specification (CLS)
Earlier we used the term '.NET Compliant Language' and stated that all the .NET compliant languages can make use of CLR and FCL. But what makes a language '.NET compliant language'? The answer is the Common Language Specification (CLS). Microsoft has released a small set of specifications that each language should meet to qualify as a .NET Compliant Language. As IL is a very rich language, it is not necessary for a language to implement all the IL functionality, rather it meets the small subset of it, CLS, to qualify as a .NET compliant language, which is the reason why so many languages (procedural and OO) are now running under .Net umbrella. CLS basically addresses to language design issues and lays certain standards like there should be no global function declaration, no pointers, no multiple inheritance and things like that. The important point to note here is that if you keep your code within the CLS boundary, your code is guaranteed to be usable in any other .Net language.
Common Type System (CTS)
.NET also defines a Common Type System (CTS). Like CLS, CTS is also a set of standards. CTS defines the basic data types that IL understands. Each .NET compliant language should map its data types to these standard data types. This makes it possible for the 2 languages to communicate with each other by passing/receiving parameters to/from each other. For example, CTS defines a type Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and VB.Net through its Integer data type.
Garbage Collector (GC)
CLR also contains Garbage Collector (GC) which runs in a low-priority thread and checks for un-referenced dynamically allocated memory space. If it finds some data that is no more referenced by any variable/reference, it re-claims it and returns the occupied memory back to the Operating System; so that it can be used by other programs as necessary. The presence of standard Garbage Collector frees the programmer from keeping track of dangling data.
Sayeed RahmanPosted Oct 14, 2021, 12:29 PM
(From DOCS) .NET's garbage collector manages the allocation and release of memory for your application. Each time you create a new object, the common language runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Only when the GC finds lack of space for new memory allocation for new objects, it performs a collection in order to free some memory.
Vahid CheshmiPosted Dec 24, 2018, 11:19 PM
Thanks, but as I read the latest book named Pro C# written by Andrew Troelsen and Philip Japikse,published by Apress,the Base Class Library is a part of Framework Class Library in which Base Class Library has (IO,Streams,Sockets,Security,Reflection,UI) inspite of FCL.I get confused about these description,which one is correct?
thotakura amruthaPosted Oct 26, 2018, 5:36 AM
U need to explain much about an assembly than about .net framework
Phillip LeePosted Aug 19, 2018, 12:14 PM
Clear and concise, I found this article to be a good overall look at assemblies. It also contained basic explanation of how the .Net framework (FCL) and .Net architecture (compiling .Net lang to MSIL which is run through JITer by CLR at runtime to form native executable code as per needs dictated by OS and hardware. Nice job!
Pankaj YadavPosted Nov 24, 2017, 4:41 AM
You didnot define well only Definition Please Provide Program with Examples if you Want Share your knowledge to EveryBody so Defintion is already Define in Google And microsoft Sites
Pankaj YadavPosted Nov 24, 2017, 4:39 AM
Please Provide Command How to add Assembly in GAC(global Assembly Cache)
SubashPosted Nov 22, 2016, 8:28 PM
Very nice information shared thanks for nice article
Anu VPosted Jul 27, 2016, 12:49 AM
Nice
kalu singh raoPosted Jul 8, 2016, 1:20 AM
Nice...
Akash MalhotraPosted Feb 5, 2016, 11:50 AM
Thanks for sharing
Mohan PatilPosted Jan 15, 2016, 10:17 AM
Very helpful information in brief
Akash MalhotraPosted Aug 25, 2015, 4:31 PM
Great article Sir....many doubts have been cleared from single article
Bhavana KyPosted Feb 13, 2015, 6:25 AM
Now I understood clear meanings of each component of .net framework
Neetu ChaudhariPosted Nov 29, 2012, 1:58 AM
really very helpful n informative article . thanx
Ammar MansuriPosted Jan 3, 2012, 3:53 AM
Very Good Article for understanding of .net framework. Thanks for such a nice article.
Tejas LakhalaniPosted Mar 28, 2011, 1:09 PM
Great Description..it provides the core information about assembly..Thank you..Very Much !! Can you please tell us how assembly is look like ??
Kuldeep PrasadPosted Mar 7, 2011, 12:19 AM
it is a superb article on .net
Candy FordeditedPosted Jan 14, 2011, 1:20 AMEdited Jan 14, 2011, 1:21 AM
Hi Thiru, Assemblies are the heart of .net framework and you have chosen that topic and explained it very clearly. Thanks for this. I had many doubts in assemblies, now after seeing your solution it gets cleared. Good and keep on posting blogs like this. http://godwinsblog.cdtech.in/2010/12/application-attempted-to-perform.html
Waheed AlkhateebPosted Dec 29, 2010, 5:08 AM
I just want to thank you Mr. Thiru Balaje It's really useful article
Arpan PatelPosted Jul 23, 2010, 4:52 AM
This is a very good site for geting a information about Dot Net.
harshal dhotePosted Dec 21, 2008, 2:37 AM
It can be better understood if explained with example.