2.3 Shared Assemblies

Assemblies can be private or shared, as illustrated by Figure 2-3. Each application that uses a private assembly has its own copy, which is stored alongside the other application components. If there are two applications installed on the same computer, and each application relies on the same private assembly, then there will be two copies of the assembly files installed. Each time you install a new application that relies on the private assembly, you create new instances of the assembly files on disk. Each assembly is independent of the others, and each application is completely self-contained.

Figure 2-3. Private and shared assemblies

By contrast, several applications can use a single instance of a shared assembly. The assembly is placed in a common location (a shared directory or network server), and every application that requires the assembly uses the same assembly disk files. More than one copy of a shared assembly can be installed, and groups of applications can rely on different instances, as illustrated by Figure 2-4.

Figure 2-4. Groups of applications relying on multiple identical private assemblies

The .NET Framework also provides the Global Assembly Cache (GAC), which is a central repository for shared assemblies. All applications that rely on a shared assembly stored in the GAC use the same disk files, as illustrated by Figure 2-5; such applications do not need to be configured to find shared assemblies in specific locations; the GAC is always available to all applications. See Section 2.5.1 for further details.

Figure 2-5. The GAC hosts shared assemblies

When we say that applications "share" an assembly, we mean that they use the same disk file. Each application is given its own copy of the data types contained in the assembly, and no data is shared between the applications. See Chapter 4 for more information on the role of an assembly in an application.

The benefits of sharing an assembly are administrative the assembly security policies and configuration that we discuss in the following chapters are applied to a shared assembly once, affecting all of the applications that rely on the assembly, whereas each instance of a private assembly must be configured individually.

Programming. NET Security
Programming .Net Security
ISBN: 0596004427
EAN: 2147483647
Year: 2005
Pages: 346

Similar book on Amazon

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