Assemblies - Private, Public/Shared, Single File, Multi File, Static, Dynamic, Satellite and Resource Only
Dated: 05 Sep, 2010 10:43:56 AM
What are Private Assemblies?
An assembly that can be referred only by the project in which it is placed is a private assembly. The private assembly is stored in the application's folder or a sub-folder within (Generally, they are stored in the bin folder of the application). If you wish to re-use a private assembly in another project, you will have to add reference to that assembly and the assembly will be copied to the (other) application's directory as well.
In other words, if two applications are using the same assembly which is built as private assembly, both the applications will have their own copy of the assembly's .dll file.
What are Public/Shared Assemblies?
Sometimes, it is required that the same assembly will be used by many applications. Take the case that in your company, you are developing applications on .NET platform. In all your applications, the authentication will be carried out the same way (using the same set of instructions, querying the same database, etc). So, you can re-use this code in all the different solutions that you are using. One way will be to use private assemblies and put the dll file in every solution's bin folder, thereby making multiple copies of the same file on your computer. (This also will create problem during updates). The other option is to put this code in a shared assembly that will be shared among all the applications.
To create a shared assembly, we have to provide strong name to the assembly and then they are placed in the Global Assembly Cache (GAC). The GAC is a location on your windows system where the shared assemblies are stored. You can see the shared assemblies in GAC at the following location:
C:\Windows\Assembly (assuming that windows is installed in folder C:\Windows)
The .NET Framework library is provided as a shared assemblies.
What are single file Assemblies?
A single file assembly is an assembly that contains all the component blocks of an assembly viz. metadata, manifest, MSIL and resources. (remember, resources are optional, they may or may not be present in an assembly)
What are multi file Assemblies?
Multi-file assemblies are assemblies that consist of more than one files. Among these files, at least one will have all the component blocks of an assembly while the others are required to only have MSIL and metadata.
Note: Multi file assemblies cannot be created with Visual Studio 2005 IDE for C# and VB.NET. You should use command line compilers to create multi-file assemblies.
What are static assemblies?
Assemblies that are stored on the disk, loaded from there and executed are static assemblies. The static assemblies are first created and then execute again and again. Most of the time we use static assemblies only. Applications that require dynamic assemblies are very rare.
What are dynamic assemblies?
Sometimes, it is required to build an assembly on-the-fly (dynamically) these assemblies are created and stored in memory and executed from there. The nature (and logic) of the assembly may change every time it is created.
Use Reflection.Emit to create dynamic assemblies.
What are satellite assemblies?
A satellite assembly is an assembly that contains language specific resources. Sometimes, in an application, it is required to support multiple languages. There can be multiple satellite assemblies working side-by-side as they are installed in the language specific folders.
What are resrouce only assemblies?
A resource only assembly is an assembly that contain only the resources such as strings, icons, bitmaps, etc. While satellite assemblies contain language specific resources, resource only assemblies contains general resources.
Like this article? Now share it with your friends