Browsing the Global Assembly Cache

On occassion one might have the need to browse .NET's Global Assembly Cache -- to manually update a file during development or to remove an assembly left behind by an installer. Normally you'd use gacutil to add or remove assemblies from the GAC during testing and development. However if the assembly was added by an installer, gacutil refuses to remove it.

Warning: Taking any of the actions outlined in this entry may hose your system -- all standard disclaimers apply.

In the past I've resorted to the Command Prompt and traversed the C:\Windows\assembly folder to delete an existing assembly and it's containing folder. Then I started mapping \\127.0.0.1\C$\windows\assembly (which takes advantage of pre-defined administrative shares) to the G:\ drive.

Neither of these options is terribly difficult, but they aren't all that convenient either. I've recently discovered a method that is! Like many special folders like the Fonts folder, Windows abstracts the underlying file system into a more simplified view of the contained files. The view is triggered by the presence of a Desktop.ini file in the root folder. Removing Desktop.ini returns C:\Windows\assembly to a regular folder.

Once you have access to the GAC as a file system it's easy to overwrite files during development -- or delete persistent assemblies after uninstalling an application. To make it easy to turn on and off, I've created two simply batch scripts to automate it.

Enabling GAC Browsing

@echo off
SET INI=%SYSTEMROOT%\assembly\Desktop.ini
IF NOT EXIST %INI% EXIT /B
attrib -s -h "%INI%"
ren "%INI%" "Desktop.old"

Restoring GAC to Original State

@echo off
SET OLD=%SYSTEMROOT%\assembly\Desktop.old
SET INI=%SYSTEMROOT%\assembly\Desktop.ini
IF NOT EXIST %OLD% EXIT /B
ren "%OLD%" "Desktop.ini"
attrib +s +h "%INI%"

To save a few seconds typing, you can download the pre-made scripts.

Related Articles

Published : Aug 22, 2009
Views : 8115

Subscribe Subscribe | Blog Home

Downloads

Tags

  • tip