Mainly serves as my backup reference on programming & technology. Plus some random thoughts
- HOME
- PROGRAMMING
- TECHNOLOGIES
- GENERAL
- ABOUT ME
What are the different types of assemblies? Satellite assembly?
2008-10-06
An assembly may be Public or Private. A public assembly is also called a Shared Assembly. An assembly is the basic building block in .NET. It is the compiled format of a class, that contains Metadata, Manisfest & Intermediate Language code. An assembly may be either Public or Private. A public assembly means the same as Shared Assembly. Private Assembly - This type of assembly is used by a single application. It is stored in the application's directory or the applications sub-directory. There is no version constraint in a private assembly. Shared Assembly or Public Assembly - A shared assembly has version constraint. It is stored in the Global Assembly Cache (GAC). GAC is a repository of shared assemblies maintained by the .NET runtime. It is located at C:\Windows\Assembly OR C:\Winnt\Assembly. The shared assemblies may be used by many applications. To make an assembly a shared assembly, it has to be strongly named. In order to share an assembly with many applications, it must have a strong name. A Strong Name assembly is an assembly that has its own identity, through its version and uniqueness. In order to convert a private assembly to a shared assembly, i.e. to create a strongly named assembly, follow the steps below... 1) Create a strong key using the sn.exe tool. This is used to created a cryptographic key pair. The key pair that is generated by the Strong Name tool can be kept in a file or we can store it our your local machine's Crytographic Service Provider (CSP). For this, goto the .NET command interpreter, and type the following... sn -k C:\samplekey.snk This will create a strong key and save it to the location C:\samplekey.snk 2) If the key is stored in a file, just like we have done above, we use the attribute AssemblyKeyFileAttribute. This belongs to the namespace System.Reflection.AssemblyKeyFileAttribute. If the key was in the CSP, we would make use of System.Reflection.AssemblyKeyNameAttribute. Go to the assemblyinfo.vb file of your project. Open this file. Make the following changes in this file... We may write this in our code as well, like this... Imports System.Reflection Namespace StrongName Public class Sample End Class End Namespace 3) Build your project. Your assembly is now strongly named. Installing the Shared assembly in GAC... Go to .NET command interpreter, use the tool gacutil.exe Type the following... gacutil /i sampleclass.dll To uninstall it, use... gacutil /u sampleclass.dll. Visual Studio.NET provides a GUI tool for viewing all shared assemblies in the GAC. A Satellite Assembly - is an assembly that contains only resources, and no code. The resources are location specific. A satellite assembly is associated with a main assembly, the one that actually contains the code.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment