Search code examples
gac

Why does GACUtil claim to install an assembly to the GAC but fail in reality?


I have an assembly: SomeAssembly.dll

I have GACUtil's folder on my path: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools

I change to the folder where SomeAssembly.dll is, execute

GACUtil /i SomeAssembly.dll

The response is:

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

I check C:\Windows\Assembly, but my assembly does not appear to be there.

I return to my command window (which I note has Administrator rights) and type:

GACUtil /l SomeAssembly.dll

and the response confirms...

Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

Number of items = 0

So It seems SomeAssembly.dll is not in the GAC

Why?


Solution

  • Leave off the .dll extension when using gacutil /l and it should correctly report your assembly.

    Also, I suspect there might be some sort of 32/64-bit mixup going on. When you're viewing C:\Windows\Assembly via Windows Explorer, you're likely seeing the 32-bit GAC only.

    [UPDATE: looks like .NET 4 stores GAC assemblies in C:\Windows\Microsoft.NET\assembly so you're only see CLR v2.0 assemblies in C:\Windows\assembly.]

    To look at the real contents of the (v2 CLR) GAC directory view it without the Explorer shell extension - a quick way to do this is to map a drive to the directory using subst and view it through that, e.g.:

    C:\>subst G: c:\Windows\assembly
    C:\>start G: