Friday, 27 May 2011

Shared Assemblies


Shared assemblies are intended to be common libraries that any other application can use. Because any other software can access a shared assembly, more precautions need to be taken against the following risks:


❑ Name collisions, where another company ’ s shared assembly implements types that have the
same names as those in your shared assembly. Because client code can theoretically have access to both assemblies simultaneously, this could be a serious problem.


❑ The risk of an assembly being overwritten by a different version of the same assembly — the
new version being incompatible with some existing client code.


The solution to these problems is placing shared assemblies in a special directory subtree in the file system, known as the global assembly cache (GAC). Unlike with private assemblies, this cannot be done by simply copying the assembly into the appropriate folder — it needs to be specifically installed into the cache. This process can be performed by a number of .NET utilities and requires certain checks on the assembly, as well as the set up of a small folder hierarchy within the assembly cache that is used to ensure assembly integrity.
To prevent name collisions, shared assemblies are given a name based on private key cryptography (private assemblies are simply given the same name as their main file name). This name is known as a strong name ; it is guaranteed to be unique and must be quoted by applications that reference a shared assembly.
Problems associated with the risk of overwriting an assembly are addressed by specifying version information in the assembly manifest and by allowing side - by - side installations.

No comments:

Post a Comment