I'm trying to register a .DLL
in the GAC
.
Currently I'm having trouble to prove it has been added to the assembly.
Using the command
C:\Windows\System32>%programfiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe -i "path\to\my\file.dll"
The prompt tells me that the assembly has been added to the cache.
When checking with
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>gacutil.exe -l file.dll
It says that there are 0 elements in the assembly.
Via Powershell
commands, I'm trying to add the DLL
like this:
PS C:\WINDOWS\system32> Add-Type -AssemblyName "System.EnterpriseServices"
PS C:\WINDOWS\system32> $publish = New-Object System.EnterpriseServices.Internal.Publish
PS C:\WINDOWS\system32> $publish.GacInstall("file.dll")
What did I do wrong? How can I add the .DLL
to the GAC
? The best way (for me) would be doing that with Powershell
.
Remember to run PowerShell as administrator or this won't work.
$dllpath = c:\path\yourdll.dll
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall($dllpath)
You will likely need to restart whatever related service or program after this, for example:
if (Get-Service "YourService" -ErrorAction SilentlyContinue)
{
Stop-Service -Name 'YourService'
Start-Service -Name 'YourService'
}
Or just restart your computer.