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 }
  • 相关阅读:
    Find the Longest Word in a String
    Check for Palindromes
    Factorialize a Number
    Reverse a String
    Java中的线程概念
    websocket 实现实时消息推送
    linux安装tomcat, jdk出现的问题
    JSON, list, 前台显示
    数据库NULL和 ‘’ 区别
    js获取后台json数据显示在jsp页面元素
  • 原文地址:https://www.cnblogs.com/smartisn/p/15348807.html
Copyright © 2011-2022 走看看