Installing .NET 4.0 Assemblies to the Global Assembly Cache (GAC)

0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×

I had an interesting problem today which helped me learn a little about some changes to the way .NET 4.0 assemblies are handled. I was passed a couple of .NET 4.0 assemblies to add to the GAC on one of our windows 2008 x64 servers. I didn’t think much of it until I got started!

I first started by trying to install the assemblies using the gacutil batch script I’d always been using – it looked something like this:

This all looks fine and is what you’d expect – I’d copied the gacutil from “C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin” on my dev machine to the same directory as the batch file (on the server) and then executed the batch file. I was then presented with the following error:

At this point I double checked that the .NET framework 4.0 was installed (which it was). It turns out that for .NET framework 4 assemblies, you have to use the newer gacutil, installed with Microsoft Windows SDK for Windows 7 and .NET Framework 4, found here:

So I installed the aforementioned SDK, got the newer gacutil (from C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\)and attempted again. This time I got no errors, but also no confirmation that the assembly was installed in the GAC. So I checked the GAC (%windir%\windows\assembly), and found that the assembly had not installed!

After a little more digging I found that the .NET framework 4.0 introduced a NEW GAC, meaning we have 2 GACs to manage – one for .net 2.0-3.5, and one for .net 4.0. The new .net framework 4.0 gac is located at %windir%\Microsoft.NET\assembly\ – so I checked this and to my shock, the assembly was not installed in there either!

Finally, I found my answer from MarkdeCates in this forum post: It seems that as well as copying the gacutil.exe, we also need to copy gacutil.exe.config and gacutlrc.dll (which is located in the 1033 subfolder). If these additional files are not copied, the gacutil doesn’t throw an error…in fact it doesn’t do anything.

So I finally got there, albeit a little confused!!


, ,

The Essential App Marketing Kit
Subscribe To My Newsletter To Get an Entire Chapter From The Book for FREE
Never display this again
0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×