Wednesday, February 10, 2016

Where is gacutil.exe?

If you are looking for gacutil.exe, you may have noticed that it no longer ships natively with the .NET Framework and instead ships separately with the Microsoft Windows SDK.

Depending on what OS you are running will determine what version of the Microsoft Windows SDK you will want to install, but for this example, I will use the Microsoft Windows SDK for Windows 7 and .NET Framework 4: https://www.microsoft.com/en-us/download/details.aspx?id=8279

One of the confusing things about this version of the Microsoft Windows SDK is that it ships with 2 versions of gacutil:

  • gacutil.exe for .NET Framework v. 3.5
  • gacutil.exe for .NET Framework v. 4.0
If you use the default location for gacutil.exe, you will be using the .NET Framework v. 3.5 version:

  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\gacutil.exe
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\x64\gacutil.exe 

However, the location of gacutil.exe for .NET Framework v. 4.0 is located here:

  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\gacutil.exe
  • C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\x64\gacutil.exe
Therefore, if you are targeting .NET Assemblies for .NET 3.5 and .NET 2.0, then you will want to use the older version of gacutil.exe, but if you are targeting .NET Assemblies for .NET 4.0 and .NET 4.5, then you will instead want to use the newer version of gacutil.exe to target these assemblies.

If you accidentally use an older version of gacutil.exe against a newer .NET assembly (ex. gacutil.exe for .NET 3.5 against a .NET 4.0/4.5 assembly), you will encounter the following 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."

If you are interested in the other Windows SDKs, you can check them out here:

No comments:

Post a Comment