Global Assembly Cache (GAC) in the .NET Framework is a repository that stores and manages shared assemblies. Registering a DLL ( Dynamic Link Library) in the GAC ensures that it can be easily assessed and used by applications across the System.
The PowerShell provides a convenient way to register a DLL in the GAC.
To install the Dll in GAC using PowerShell, follow the below steps and code snippet.
- Open the PowerShell – Launch the PowerShell terminal with administrator privileges.
- Register a DLL – Run the following PowerShell cmdlets to register a DLL in the GAC.
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacInstall("D:\PS\Npgpsql.dll")
In the above PowerShell script,
[System.Reflection.Assembly] class load and assembly with the specified full name. It includes information about the assembly name, version, culture, and public key token.
$publish variable is a new instance of the “
Publish” class from the “
$publish variable uses the
GacInsall method to register a DLL on the GAC.
I hope the above article on how to register DLL in the GAC using PowerShell is helpful to you.
You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.