Close

GAC Changes in Windows Server 2012

Prior to Windows Server 2012, gacutil is typically used to install DLL files in the Windows Global Assembly Cache (GAC). With Windows Server 2012 unfortunately it's not quite so easy. Being able to simply open the GAC in Explorer and drag/drop is gone (so yeah, no shell!). Also GacUtil.exe is not present on the server by default as part of runtime. In order to use gacutil like earlier versions of Windows, we would need to install the .NET SDK on the server which is not really a good idea (defense in depth; only have runtime on server). Of course copying-pasting gacutil.exe doesn’t work (dependencies).

Since we are all too familiar to.NET versions prior to 4.0, GAC used to be in the c:\windows\assembly window and had a custom shell extension to flatten the directory structure into a list of assemblies. Like mentioned earlier, the shell extension is no longer used for .NET versions 4.0 and up. Since we have .NET 4.5 on server machines, its GAC is stored in c:\windows\microsoft.net\assembly. You just get to see the actual directory structure. Locating the assembly isn't that difficult, start in the GAC_MSIL directory and you should have no trouble locating your assembly there by its name. Locate the folder with the same display name as your assembly. It will have a subdirectory that has an unspeakable name that's based on the version and public key token, that subdirectory contains the DLL.

Therefore, PowerShell is the recommended approach to do the GAC install. Following are the instructions on how to install the dll to GAC in Windows 2012 Server. For EL6, we ended up writing the following powershell script.

Set-location "C:\tmp"
 [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
 $publish = New-Object System.EnterpriseServices.Internal.Publish
 $publish.GacInstall("c:\tmp\Microsoft.Practices.EnterpriseLibrary.Common.dll")
 $publish.GacInstall("c:\tmp\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll")
 $publish.GacInstall("c:\tmp\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll")
 $publish.GacInstall("c:\tmp\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll")
 $publish.GacInstall("c:\tmp\Microsoft.Practices.EnterpriseLibrary.Logging.dll")

Happy Coding!

Share