Section 5.2. Assembly Deployment Models


5.2. Assembly Deployment Models

.NET supports two assembly deployment models: private and shared. With a private assembly, each client application maintains its own private local copy of the assembly. Deploying a private assembly is as simple as copying it to the directory of the application using it. Although client applications will typically deploy all their required private assemblies during installation, nothing prevents a new private assembly from being copied over later. This allows for different lifecycles for the client and server and lets both evolve separately. When you copy a new version of a private assembly to the client directory, if the application has a previous copy of the assembly, the new copy overrides the old copy because a file directory can't have multiple files with the same name. Private assemblies are usually backward-compatible, meaning that they must support all the functionality available in the previous version. If that isn't the case, an old client application will break when it tries to access functionality in the new version that differs from the old version.

A shared assembly is an assembly that can be used by multiple client applications. You must install shared assemblies in a well-known global location called the global assembly cache (GAC). The GAC can support multiple versions of the shared assembly, enabling side-by-side execution of different versions of the assembly. That means that if an older version is still present, a shared assembly doesn't have to be backward-compatible. Shared assemblies simplify complicated deployment situations, especially for framework or third-party component vendors, because when a new version is installed in the GAC it instantly becomes available for all client applications on that machine. This chapter dedicates a separate section to generating and using shared assemblies.

The .NET entity responsible for managing assembly compatibility and for making sure a client application always gets a compatible assembly is called the assembly resolver. When a client application declares a type whose assembly isn't yet loaded, .NET looks in the client's assembly manifest to find the exact name and version of the server assembly the client expects and then passes that information to the assembly resolver. The assembly resolver always tries to give the client assembly a version-compatible server assembly. The resolver first looks in the GAC (for strongly named assemblies only, as explained next), and loads the compatible assembly from there if it is found. If no compatible assembly is found in the GAC, the resolver looks in the client application folder. If the client application folder contains a compatible private version of the assembly (it can have only one such assembly file in its folder), the resolver loads and uses that version. .NET throws an exception if no matching private assembly is found. By default, .NET does not let a client application interact with an incompatible assembly.

Avoid mixing and matching private and shared server assemblies (that is, different versions of the same assembly, one used as private and some as shared). This can lead to conflicts between older and newer versions that are difficult to discern and resolve.




Programming. NET Components
Programming .NET Components, 2nd Edition
ISBN: 0596102070
EAN: 2147483647
Year: 2003
Pages: 145
Authors: Juval Lowy

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net