Code snippets to add remove an assembly from GAC -
Add reference to - System.EnterpriseServices
using System.EnterpriseServices.Internal;
var path = "the absolute path of assembly";
Publish publish = new Publish();
publish.GacInstall(path);
publish.GacRemove(path);
Reference:
https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-remove-an-assembly-from-the-gac