zoukankan      html  css  js  c++  java
  • C# 调用dll (绝对路径亲测可用,使用强名称需要在GAC中)

    代码:

     1 using System;
     2 using System.Reflection;
     3 namespace Assembly_Load
     4 {
     5     class Program
     6     {
     7         public static void Get_GAC_assembly()
     8         {
     9             string longName = "Roslynator.Core, Version=2.1.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e";
    10             Assembly assem = Assembly.Load(longName);
    11             if (assem == null)
    12                 Console.WriteLine("Unable to load assembly...");
    13             else
    14                 Console.WriteLine(assem.FullName);
    15         }
    16         public static void Get_absolute_path()
    17         {
    18             byte[] buffer = System.IO.File.ReadAllBytes(@"D:VS2017WorkSpaceBUGExceptionSystem.MissingMethodExceptionAssembly-LoadAssembly-LoaddataRoslynator.Core.dll");
    19             //Load assembly using byte array
    20             Assembly assembly = Assembly.Load(buffer);
    21             Console.WriteLine(assembly.FullName);
    22             Console.WriteLine("***");
    23         }
    24         static void Main(string[] args)
    25         {
    26             string longName = "Roslynator.Core, Version=2.1.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e";
    27             Assembly assem = Assembly.Load(longName);
    28             if (assem == null)
    29                 Console.WriteLine("Unable to load assembly...");
    30             else
    31                 Console.WriteLine(assem.FullName);
    32         }
    33     }
    34 }
  • 相关阅读:
    利用密钥通过ssh互访
    rsync参数及通信
    cacti 安装
    地区排名脚本 一千三百多行代码
    调用分隔符的数组。
    select case when
    jquery 设置select 默认值
    常见的分析函数
    oracle分析函数 之分组累加求和
    ORACLE的表被 另一个用户锁定,如何解除..
  • 原文地址:https://www.cnblogs.com/smartisn/p/15348807.html
Copyright © 2011-2022 走看看