How to register an Assembly in GAC without using GacUtil.exe !

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-

  1. Create a Console Application.
  2. Add a new reference to the Project – System.EnterpriseServices
  3. Add ‘using System.EnterpriseServices.Internal‘ to your .cs file.
  4. Add the following code to main method-

GAC

     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 !

Categories
Comments
All comments.
Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.