C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Assemblies - An Introduction


Posted Date: 05 May 2006    Resource Type: Articles    Category: .NET Framework
Author: Vakul Kumar MoreMember Level: Silver    
Rating: Points: 10



Assemblies


An assembly is a collection of one or more files which form a logical unit. An assembly can be a .exe,.dll etc., An assembly can be a managed module or unmanaged module.
An assembly is a smallest unit of reuse, security and versioning. In other words, an assembly is the building block of .NET application.

Assemblies are made of two parts:
• Manifest (Describes the assembly, providing the logical attributes shared by all the modules and all components in the assembly. The manifest contains the assembly name, version number, locale and an optional strong name that uniquely identifies the assembly.)
• MSIL (Microsoft Intermediate Language is a language used as the output of a number of compilers (C#, VB.NET etc.,)

Disadvantages of DLL


There are many problems with conventional dll’s which led to the recommendation to the users by Microsoft. Three basic disadvantages of dll are
• Version Incompatibility
• Location Intransparency
• Language Depandency.

All the above problems are successfully eradicated with assemblies. Though, other technologies like COM and DCOM solves the above problems by using interfaces, they have got their own disadvantages like Performance and Deployment. By using assemblies, we can even solve these problems.

Earlier developers used to share libraries of code through DLL. To use the DLL that is developed by another developer for another application, you have to register that DLL in your machine. In .NET, the assembly is created by default whenever a DLL is built. By using classes located in the System.Reflection namespace, details of the manifest of the assembly can be checked.

Types of assemblies


Assemblies are of two types:
1. Private Assemblies
2. Public/Shared Assemblies
3. Satellite Assemblies

Private Assemblies:


Private assemblies are the ones intended only for one application. The files of that assembly must be in the same folder as the application folder or sub folder. One major advantages of the assembly is the ease of naming on a condition that there is no other assembly has the same name.

Shared Assemblies:


If the assembly is a Shared Assembly, then the naming conventions are very strict since it has to be unique across the entire system. The naming conventions should also take care of newer versions of the component being shipped. These are accomplished by giving the assembly a Shared Name. Then the assembly is placed in the global assembly cache, which is a folder in the file system reserved for shared assemblies.

Satellite Assemblies:


MSDN definition: "A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the application in that language."

Satellite assemblies are DLLs that provide culture-specific icons and text strings for your .NET application. Satellite assemblies are used to hold resources (strings, icons, bitmaps, etc.) and generally do not have code.

There are two ways to create a satellite. The first way is to use your language compiler to create a library assembly with an embedded resource and to mention the culture of the assembly using the [AssemblyCulture] custom attribute. This requires that you have at least one code file, but that file does not have to define a type or an entry point. The other way is to use the assembly linker tool, al.exe, and specify the resource and culture on the command line; this does not require a code source file.

GAC (Global Assembly Cache)


GAC stores all the shared assemblies to be used by several applications on the computer. As all COM components must register and store in Windows Registry, shared assemblies must be installed in GAC. Any assemblies to be deployed in Global assembly must have a strong name.

A strong Name key pair has to be created before deploying the assembly into the GAC. Key pair can be created by using a Strong name tool. (sn.exe). Key pair is created with an extension .snk. A strong Name can be created from the .NET Command Prompt from the application folder and typing the following command:

 Sn –k <filename>.snk 


Once the Key pair is written, the key pair file has to be linked to the application through Assemblyinfo.vb file.

Next step is to install a strong-named assembly into the global assembly cache At the command prompt, type the following command:

 Gacutil –i < assembly name> 


In this command, assembly name is the name of the assembly to install in the global assembly cache.

After installing successfully, the shared assembly can be checked from command prompt by checking the assembly folder in windows folder.

An assembly contains the version number and public key token. For example, System folder in GAC has a folder with the version number and public key value as follows:

1.0.5000.0_b77a5c561934e089.

1-Major Version
0-Minor Version
5000- Build Number
0- Revision Number
b77a5c561934e089 – Public Key Value.

Any new version of System.dll will be in the System folder with different version number and public keys values. Multiple versions of the same assembly can be installed in Global Assembly cache. Thus, Versioning and deployment problems can be solved with shared assemblies. CLR always looks into GAC for assemblies.

For the Word document version with images please visit http://www.filelodge.com/files/room25/674555/Assemblies.doc



End of the Article






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Strong naming  .  Sn tool  .  Private and shared assemblies  .  Global assembly cache  .  Gac  .  Assemblies in .net  .  Assembiles  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Generics in c# 2.0
Previous Resource: Introduction to .NET with Basic Shotcuts and Secrets for the Beginner
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use