Understanding the .NET Framework - Global Assembly Cache
(Page 7 of 8 )
The Global Assembly Cache (GAC) is a .NET mechanism that's used to explicitly share assemblies between applications. As a rule, you should use the Global Assembly Cache only for assemblies that are expressly intended to be shared among multiple .NET applications. If your application's assembly is not shared, it should remain private, and you shouldn't add it to the Global Assembly Cache.
NOTE: If you place an application in the Global Assembly Cache, you can't subsequently deploy the application using xcopy because the GAC of the target system would need to be updated in order to execute the assembly.
You can view the GAC by using Windows Explorer and navigating to the %windows%assembly folder. An example of the GAC is shown in Figure 2-6.
.NET applications are added to the GAC by using a .NET-aware installer, or you can manually drag and drop files from Windows Explorer onto the Global Assembly Cache.

Figure 2-6. Viewing the Global Assembly Cache
Assembly Security
Assembly security is controlled by policies that are enforced by the CLR. When an assembly is executed, the CLR checks to ensure that the code about to be executed is allowed by the existing security polices. When the CLR first loads an assembly, it checks the available security policy to determine the assembly's permissions. In .NET parlance, the assembly security information is referred to as evidence. Evidence includes the assembly's publisher, its site, and its zone.
Setting Permissions
An administrator can set the security polices for a .NET application by using the .NET Framework Configuration tool, mscorcfg.msc, an MMC snap-in that's included with the .NET Framework. The permissions set by the .NET Framework Configuration tool are set after the application is deployed by an administrator, and they control the application's runtime behavior-they are not set during the development process. The .NET Framework Configuration tool can set security policies based on an enterprise-based policy, a machine-based policy, or a user-based policy. Table 2-9 lists the security configuration files that are modified using the .NET Framework Security Configuration tool.
You can start the by selecting Start | Programs | Microsoft Visual Studio.NET | Visual Studio .NET Tools | Visual Studio Command Prompt. From there, you can enter mscorcfg.msc at the command line. Figure 2-7 presents an example of the .NET Framework Configuration tool.
This is chapter two of ADO.NET: The Complete Reference, by Michael and Denielle Otey (McGraw-Hill/Osborne, ISBN 0-07-222898-9, 2003). Check it out at your favorite bookstore today. Buy this book now. |
Next: Signing an Assembly >>
More .NET Articles
More By McGraw-Hill/Osborne