Add DLL to GAC using C#

Reference the system.EnterpriseServicess assembly to your project.


using System.EnterpriseServices.Internal;

public void Update(DirectoryInfo folder_GAC)
{
  //check if folder containing new dll files exists
  if(folder_GAC.exists){
    //add each dll found in this folder to the Global Assembly Cache
    foreach (FileInfo dll in folder_GAC.GetFiles("*.dll")) 
    {
      //instantiate a new Publich object and install the dll
      Publish objpublish = new Publish();
      objpublish.GacInstall(dll.FullName);
    }    
  }
}

remove an assembly from the GAC can be done by using the GacRemove(string name) method.

more information:
http://msdn.microsoft.com/en-us/library … blish.aspx

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)