If you want to install a DLL in the GAC and do not have the GACUtil.exe available. Powershell is properly the easiest way to procede.
Before Powershell you would properly just drag the DLL file into the C:\Windows\Assembly but this option is usually not available anymore.
The first line adds a reference to the assembly we need to be able to mange the GAC.
The second and third lines retrives the GAC object and publish a new DLL file to it.
The last line resets the Internet Information Services. This is only needed if your DLL file is used in a website hosted in the IIS.
Before Powershell you would properly just drag the DLL file into the C:\Windows\Assembly but this option is usually not available anymore.
Powershell - Add DLL to GAC
So to install a DLL file in the GAC simply execute the below Powershell script. Remember you migth want to run the Powershell prompt as an administrator.[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:\temp\MyDllFile.dll") iisreset
The first line adds a reference to the assembly we need to be able to mange the GAC.
The second and third lines retrives the GAC object and publish a new DLL file to it.
The last line resets the Internet Information Services. This is only needed if your DLL file is used in a website hosted in the IIS.
Powershell - Remove DLL from GAC
If you need to remove a DLL file from the GAC there is also a script for this.[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacRemove("c:\temp\MyDllFile.dll") iisreset
great post, and really helpful, however sometimes the above commands dose nothing, install or remove doesn't do any changes on the GAC, what would be the problem?
ReplyDeleteThis doesnot work for win server 2008, do we need to change any parameter?
ReplyDeleteNpotuperfho_1980 Kathy Evans https://wakelet.com/wake/jtwKt8WLGiy7LCSiWdDrM
ReplyDeleteunoritlac
tuobustrudda Nathan Plowden link
ReplyDeleteclick
click here
click
croclojuslo
optitipu Haley Johnson Bootstrap Studio
ReplyDeleteEmsisoft Anti-Malware
Norton Security
sahedkiefi