Sometime scenarios occur when the target machine does not have GacUtil.exe. GacUtil is included with Visual Studio (as part of the Microsoft SDK).
In such scenario you can register Assembly in GAC programmatically using Publish.GacInstall method. First you should sign your Assembly with a Strong Name.
Now follow the below steps-
- Create a Console Application.
- Add a new reference to the Project – System.EnterpriseServices
- Add ‘using System.EnterpriseServices.Internal‘ to your .cs file.
- Add the following code to main method-
5. Build the code.
6. Copy the .exe to the target machine and run it.
7. Verify that the Assembly is registered in GAC. GAC path- C:WINDOWSassembly
For more details on this method, refer the MSDN link.
Please leave your comments and feedback.
Thanks for checking out !