Installing a Microsoft .NET assembly into the GAC used to be fairly trivial. Unfortunately, I just spent some frustrating time learning that things have changed quite a bit with .NET 4.
I began with my .NET 4 assembly and tried to install it via the usual approach, dragging and dropping it into the %windir%\assembly folder via the Explorer shell extension. Strange; nothing happened.
A quick search revealed that for .NET 4, Microsoft, for reasons which do not seem to be well documented, have created a new GAC location, in the %windir%\Microsoft.NET folder.
Well, that was annoying, I thought: but I could deal with it. I tried dropping the file into the new GAC folder… but there is no nice Explorer shell extension for the new GAC. Doh! (for the second time)
Ok, time to drop to the command line and fire up good ol’ gacutil.exe.
I received this error message:
“Failure adding assembly to the cache: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.”
Sigh. Ok, I thought, I’ll just use the .NET 4 version of gacutil.exe. After a quick search of my PC I learned that it’s not installed with Version 4 of framework, nor with Visual Studio 10.
Yet another brick wall! But no worries – I would just download it. I found out via Matt Whetton’s Blog that I needed to download Microsoft Windows SDK for Windows 7 and .NET Framework 4 to get it, so I did (while wondering why I need to download that whole SDK to get gacutil??)
So then I found gacutil in the bin folder of the SDK and I ran it. Arrgh, it returned the same error message again!
Eventually I found the .NET 4 version of GACUtil in the SDK – it’s nestled in
C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools.
Sigh. Could Microsoft really make things any more difficult? I just wanted to install an assembly into the GAC!
By the way, if you need to copy gacutil onto a server, you will need to copy the following files to it: gacutil.exe, gacutil.exe.config and gacutlrc.dll (the last one located in the 1033 sub folder containing gacutil).