• C#通过代码判断并注册程序集到GAC


                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);
  • 相关阅读:
    java 用代码实现判断字符串的开头和结尾
    java基础 1-path
    C#基础(语句 for循环)
    C#基础(数组)
    C#基础(语句 if else)
    C#基础(变量、常量、运算符)
    继承-person
    继承-字母表
    继承-monkey
    继承-people
  • 原文地址:https://www.cnblogs.com/nanfei/p/7458253.html
Copyright © 2020-2023  润新知