Add the Namespace
"using System.EnterpriseServices.Internal;"
String SourceLocation = ConfigurationManager.AppSettings["SourceDLL"].ToString();
if (Directory.Exists(SourceLocation))
{
foreach(String sFileName in Directory.GetFiles(SourceLocation))
{
FileInfo FileName = new FileInfo(sFileName);
Publish oPublish = new Publish();
//To Remove the DLL in assembly
oPublish.GacRemove(SourceLocation + "\\" + FileName.Name.ToString());
//To Install the DLL in assembly
oPublish.GacInstall(SourceLocation + "\\" + FileName.Name.ToString());
}
}
There is no need to remove the dll seperately as mentioned in the code, it can be automatically overwritten.