var dllName = "EasyHook.dll"; var dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dllName); if (System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache(Assembly.LoadFrom(dllPath))) new System.EnterpriseServices.Internal.Publish().GacRemove(dllPath); Thread.Sleep(100); new System.EnterpriseServices.Internal.Publish().GacInstall(dllPath); Thread.Sleep(100); if (System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache(Assembly.LoadFrom(dllPath))) Console.WriteLine("{0} registered to GAC successfully.", dllName); else Console.WriteLine("{0} registered to GAC failed.", dllName); dllName = "ComplexParameterInject.dll"; dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dllName); if (System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache(Assembly.LoadFrom(dllPath))) new System.EnterpriseServices.Internal.Publish().GacRemove(dllPath); Thread.Sleep(100); new System.EnterpriseServices.Internal.Publish().GacInstall(dllPath); Thread.Sleep(100); if (System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache(Assembly.LoadFrom(dllPath))) Console.WriteLine("{0} registered to GAC successfully.", dllName); else Console.WriteLine("{0} registered to GAC failed.", dllName);