varDllName ="EasyHook.dll"; varDllPath =Path.Combine (AppDomain.CurrentDomain.BaseDirectory, dllName); if(System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache (Assembly.LoadFrom (DllPath))) NewSystem.EnterpriseServices.Internal.Publish (). Gacremove (DllPath); Thread.Sleep ( -); NewSystem.EnterpriseServices.Internal.Publish (). Gacinstall (DllPath); Thread.Sleep ( -); if(System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache (Assembly.LoadFrom (DllPath))) Console.WriteLine ("{0} registered to GAC successfully.", DllName); ElseConsole.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))) NewSystem.EnterpriseServices.Internal.Publish (). Gacremove (DllPath); Thread.Sleep ( -); NewSystem.EnterpriseServices.Internal.Publish (). Gacinstall (DllPath); Thread.Sleep ( -); if(System.Runtime.InteropServices.RuntimeEnvironment.FromGlobalAccessCache (Assembly.LoadFrom (DllPath))) Console.WriteLine ("{0} registered to GAC successfully.", DllName); ElseConsole.WriteLine ("{0} registered to GAC failed.", dllName);
C # uses code to determine and register assemblies to the GAC