Сравнивайте с английским: нажмите на абзац — оригинал откроется в окне. Кнопка EN под абзацем показывает его прямо в тексте.
Содержание
Введение
Глобальный кэш сборок (GAC) — это кэш CLI-сборок, доступный на уровне всей машины, для Common Language Infrastructure (CLI) в Microsoft .NET Framework. Использование специально контролируемого центрального репозитория решает проблемы, присущие концепции общих библиотек, и помогает избежать недостатков других решений, приводивших к таким проблемам, как "ад DLL".
The Global Assembly Cache (GAC) is a machine wide CLI assembly cache for the Common Language Infrastructure (CLI) in Microsoft's NET Framework. The approach of having a specially controlled central repository addresses the flaws in the shared library concept and helps to avoid pitfalls of other solutions that led to drawbacks like DLL hell.
Требования
Сборки, размещенные в GAC, должны соответствовать определенной схеме версионирования, позволяющей одновременное выполнение различных версий кода. В частности, такие сборки должны иметь сильное имя.
Assemblies residing in the GAC must adhere to a specific versioning scheme which allows for side by side execution of different code versions. Specifically, such assemblies must be strongly named.
Использование
Существует два способа взаимодействия с GAC: инструмент Global Assembly Cache Tool (gacutil.exe) и средство просмотра кэша сборок (shfusion.dll).
There are two ways to interact with the GAC: the Global Assembly Cache Tool (gacutil. exe) and the Assembly Cache Viewer (shfusion. dll).
Просмотр кэша сборки
Новый интерфейс, Assembly Cache Viewer, интегрирован в проводник Windows. Просмотр каталогов %windir%\assembly\ (например, C:\WINDOWS\assembly) или %WINDIR%\Microsoft.NET\assembly отображает сборки, содержащиеся в кэше, вместе с их версиями, культурой, токеном открытого ключа и архитектурой процессора. Сборки устанавливаются перетаскиванием, а удаляются выбором и нажатием клавиши Delete или с помощью контекстного меню. С выпуском .NET Framework 4 расширение оболочки Assembly Cache Viewer устарело.
The newer interface, the Assembly Cache Viewer, is integrated into Windows Explorer. Browsing %windir%\assembly\ (for example, C:\WINDOWS\assembly) or %WINDIR%\Microsoft. NET\assembly, displays the assemblies contained in the cache along with their versions, culture, public key token, and processor architecture. Assemblies are installed by dragging and dropping and uninstalled by selecting and pressing the delete key or using the context menu. With the launch of the NET Framework 4, the Assembly Cache Viewer shell extension is obsolete.
Пример использования
На компьютере установлено две сборки CLI с одинаковым именем AssemblyA, но одна имеет версию 1.0, а другая – 2.0. Поскольку обе сборки должны быть скомпилированы в файл с именем AssemblyA, они не могут находиться в одной папке в файловой системе FAT32. Вместо этого программы, которым требуется использовать конкретную версию сборки, могут использовать виртуальную файловую систему GAC.
A computer has two CLI assemblies both named AssemblyA, but one is version 1.0 and the other is version 2.0. Since it is required that both be compiled to a file named AssemblyA, they cannot exist in the same directory within the FAT32 file system. Instead, the virtual file system of the GAC can be used by programs that need to use each version of the assembly specifically.
Реализация
GAC как концепция фактически не существует в ОС Windows. Она реализована и управляется средой CLR. Папки в %systemroot% с именами assembly и Microsoft.NET\assembly (для .NET Framework 4.0) содержат все глобально доступные сборки с управляемыми именами файлов, позволяя включать в них токены версии и открытого ключа. Таким образом, различные версии могут существовать в одном и том же месте и вызываться без необходимости сохранения расположения точек входа кода последующими версиями, как это обычно происходит. Windows Explorer позволяет устанавливать сборки в эту папку методом перетаскивания, только если их установка была бы разрешена из командной строки. Приложение, обращающееся к сборке, может указать требуемую версию, и среда выполнения сможет использовать соответствующую сборку, просто обращаясь к имени файла.
The GAC as a construct does not actually exist within the Windows OS. It is implemented and managed by the CLI. The folders within %systemroot% named assembly and Microsoft. NET\assembly (for NET 4.0) contain all globally available assemblies with managed filenames so that the version and public key tokens can be included. Each version can therefore exist within the same location and be called without requiring subsequent versions to preserve code entry point locations as usual. Windows Explorer allows the drag and drop installation of assemblies into this folder only if they would otherwise be permitted to be installed from the command line. A calling application may specify a version of an assembly when referencing it, so the run time can simply refer to the filename to use the correct one.