Глобалдық Ассамблея Кеші және .NET Framework-та оның қолданылуы
Global Assembly Cache
.NET Framework-тегі GAC (Global Assembly Cache) – ортақ кітапхана мәселелерін шешетін, код нұсқаларын басқаруға көмектесетін құрал. Құрастыруларды орнату және басқару.
Ағылшыншамен салыстырыңыз: абзацты басыңыз — түпнұсқа терезеде ашылады. Абзац астындағы EN түймесі оны мәтін ішінде көрсетеді.
Мазмұны
Кіріспе
Global Assembly Cache (GAC) – Microsoft-тың .NET Framework-тағы Common Language Infrastructure (CLI) үшін машинаның барлық бөлігінде қолданылатын CLI құрастыру кэші. Арнайы басқарылатын орталық репозиторийді пайдалану ортақ кітапханалар тұжырымдамасының кемшіліктерін жоюға және 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) және Assembly Cache Viewer (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 Explorer-ге енгізілген. %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 операциялық жүйесінде физикалық түрде жоқ. Ол CLI арқылы іске асырылады және басқарылады. %systemroot% ішіндегі assembly және Microsoft.NET\assembly (NET 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.