Saturday, March 21, 2015

Global Assembly Cache (GAC) Assembly Management with Windows File Explorer

Managing the Windows 7 Global Assembly Cache (GAC)

The problem was this, I had a complex application with an installer. Post-install on a Windows 7 machine, I needed to debug the application by overwriting an assembly (DLL) that was installed with an assembly built for for debug and its corresponding PDB file. As part of the install process, the assembly was in the Global Assembly Cache (GAC).GACUtil (Gacutil.exe (Global Assembly Cache Tool)) is a command-line utility that can add assemblies to the GAC, remove assemblies from the GAC and provide a list of assemblies in the GAC.

Ultimately GACUtil is a command-line utility where Windows File Explorer is a more natural way manage the contents of the GAC. The Global Assembly Cache is just a folder, located under: C:\Windows\assembly and appears as follows on a Windows 7 machine:


What is displayed on Windows 7 when C:\Windows\Assembly is viewed in File Explorer is Assembly Viewer. The Assembler Viewer means File Explorer (under Windows 7) cannot be used to manage the GAC, hence GACUtil become a necessity. There is no convenient drag/drop or copy/paste as is the case when simply managing files with Windows Explorer.

A quick internet search revealed a technique to disable Assembly Viewer, "How to copy or replace DLLs from your GAC." The previous link is a blog posting written by Mohammed Adenwala a senior technical evangelist with Microsoft so obviously a very knowledgeable person in the Windows arena. His blog posting is all text and no screenshots. The first comment following his write up is:



The technique demonstrated Adenwala is to navigate to HKLM\Software\Microsoft\Fusion in RegEdit and to add a 32-bit DWORD key DisableCacheViewer where the value is set to 1. Rather than assume ever develop understand the previous sentences lets demonstrate with screenshots. In order to display the registry bring up Regedit which can be found under Windows 7 as follows:



When regedit is run it displays the following:


The root level kevys of the registry each have a rather long name so developers over the years have have developed a shorthand:

  • HKEY_CLASSES_ROOT is abbreviated HKCR
  • HKEY_CURRENT_USER is abbreviated HKCU
  • HKEY_LOCAL_MACHINE is abbreviated HKLM

So the instructions to disable assembly viewer should be clear now since root key abbreviations have been itemized: within Regedit navigate to HKLM\SOFTWARE\Microsoft\Fusion and create a DWORD value named, DisableCacheViewer, with a value of 1. Using RegEdit is is possible to navigate to the location, HKLM\SOFTWARE\Microsoft\Fusion, which is shown below:



To create a new key simple click the area of RegEdit where keys are normally display and select New | DWORD (32-bit) Value:


When a new value is created it will be appear in RegEdit as follows, New Value #1:


Right clicking on the name, New Value #1, it is possible to rename it to DisableCacheViewer which is demonstrated below:


Double clicking on the name DisableCacheViewer  allows this value to be edited where a value of 1 can be specified:


Once the value of DisableCacheViewer  has be set to 1 it will appear as follows in RegEdit:


File Explorer now shows the files within the GAC (C:\Windows\Assembly) sans Assembly Viewer (no reboot required):


Below it is shown that it is simply possible to navigate to any assembly with the GAC such as AuditPolicyGPManagedStubsInterop.dll, 32-bit instance, version, \6.1.0.0, singing key 31bf3856ad364e35:



A bunch of screenshots demonstrating how to display GAC files within File Explorer should not be construed as criticism of Mr. Adenwala's blog posting. His posting provided enough information for most developers to access the DLL's in the GAC via File Explorer. My comment to Mr. Adenwala's blog posting is as follows:

Managing the Windows 8 Global Assembly Cache (GAC)

Throughout this posting, the term Windows 7 was used to specify how Assembly Viewer was dispalyed when viewing C:\Windows\Assembly was viewed in File Explorer. Under Windows 8 the following is displayed in Windows Explorer when C:\Windows\Assembly is accessed:


An experiment is in order to see if Assembly Viewer works within File Explorer on Windows 8. The registry key,. DisableCacheViewer, was added (type DWOD) under HKLM\Software\Microsoft\Fusion and the value set to 0 (which means Assembly Viewer is enabled).


Even after DisableCacheViewer is set to zero Assembly Viewer is not displayed.

Windows 8 the operating system that brought: :
  • Support for 64-bit Hyper-V virtual guest machines
  • Disabled Assembly Viewer when access the C:\Windows\Assembly
How is C:\Windows\Assembly displayed in Windows 10? Well... That is an exercise left to the reader.

1 comment :

  1. This comment has been removed by a blog administrator.

    ReplyDelete