Remote Gacutil: Managing Assemblies Without RDP Access

Written by

in

To fix Global Assembly Cache (GAC) issues on remote servers using gacutil.exe, you must execute the utility through a remote management framework like PowerShell Remoting or PsExec. Because gacutil.exe is a developer tool and not installed on production servers by default, you must also ensure the executable or the necessary library files are accessible to the remote machine. Prerequisites

Administrator Rights: You need local administrator privileges on the target remote machine.

PowerShell Remoting: WinRM must be enabled and configured on the remote server.

Tool Availability: gacutil.exe must be copied to the remote machine or hosted on an accessible network share. Method 1: Using PowerShell Remoting (Recommended)

PowerShell Remoting provides a secure and native way to execute commands on remote Windows servers.

Establish a Remote SessionOpen PowerShell as an Administrator on your local machine and connect to the remote server: powershell

Enter-PSSession -ComputerName “RemoteServerName” -Credential (Get-Credential) Use code with caution.

Install an Assembly RemotelyNavigate to the folder containing gacutil.exe and run the installation command: powershell .\gacutil.exe /i “C:\Path\To\YourAssembly.dll” Use code with caution.

Uninstall a Broken AssemblyRemove a specific version or a specific assembly by its strong name: powershell

.\gacutil.exe /u “YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdef1234567890” Use code with caution.

Verify the Cache StateList the installed versions of the assembly to confirm the fix: powershell .\gacutil.exe /l “YourAssembly” Use code with caution. Method 2: Using PsExec (Alternative)

If PowerShell Remoting is blocked by your network security policies, Sysinternals PsExec can run the utility remotely over RPC/SMB. Run the Remote Installation:

psexec \RemoteServerName -u AdminUser -p AdminPassword “C:\Tools\gacutil.exe” /i “C:\Tools\YourAssembly.dll” Use code with caution. Best Practices and Troubleshooting

Missing Dependencies: gacutil.exe requires gacutil.exe.config in the same directory to target the correct .NET runtime version. Always copy both files together.

Strong Name Requirement: The GAC only accepts assemblies that are signed with a strong name key. Unsigned assemblies will throw an installation error.

IIS Recycle: If you are updating a DLL used by a web application, run iisreset or recycle the specific AppPool via your remote session to force IIS to load the new assembly.

Native Alternative: If copying gacutil.exe is restricted by security policies, you can use native PowerShell to interact with the GAC via the .NET API directly within your remote session: powershell

[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:\Path\To\YourAssembly.dll”) Use code with caution.

To help tailor these steps to your specific situation, please let me know: What error message or behavior are you experiencing? Which .NET Framework version does your assembly target?

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *