zoukankan      html  css  js  c++  java
  • 调用动态链接库中的方法。

     1   string strPath = HttpContext.Current.Server.MapPath("/封闭式DLL");//获取链接库的虚拟路径的物理路径
     2                 DirectoryInfo df = new DirectoryInfo(strPath);//初始化路径下的新实例。
     3                 System.IO.FileInfo[] fr = df.GetFiles();
     4                 string ReStr = "";
     5                 foreach (System.IO.FileInfo f in fr)
     6                 {
     7                     if (f.Name.EndsWith("Grid30Register.dll"))
     8                     {
     9                         System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFile(f.FullName);//加载程序集。
    10                         Type tp = ass.GetType("Grid30Register.CreateOperateClass");//获取指定的程序集对象(空间名.类名)。
    11                         MethodInfo meth = tp.GetMethod("InsertSunUnitLib");//搜索指定的公共方法。
    12                         object obj = System.Activator.CreateInstance(tp, new object[] { GridConfig.UserServerIP, GridConfig.UserServerIP, GridConfig.UserServerIP, KbaseConfig.ServerIP, KbaseConfig.ServerUserName, KbaseConfig.ServerPsw, "", GridConfig.Language });//使用与指定参数匹配度最高的构造函数创建指定类型实例。
    13                         ReStr = meth.Invoke(obj, new object[] { entity.PUnitUserName, subUnitInfo.UserName, en.Encrypt3DES(subUnitInfo.Password), en.Encrypt3DES(subUnitInfo.superPW), subUnitInfo.RealName, subUnitInfo.Department, subUnitInfo.ManageTel, subUnitInfo.EMail, string.Empty, subUnitInfo.UnitName, subUnitInfo.RealName, subUnitInfo.Department, subUnitInfo.ManageTel, subUnitInfo.EMail }).ToString();//使用指定参数调用当前实例所表示的方法或构造函数。
    14                     }
    15                 }

    构造函数是在创建给定类型的对象时执行的类方法。构造函数具有与类相同的名称,里面的参数类型或者数量不同。

  • 相关阅读:
    轮子来袭 vJine.Core Orm 之 03_架构分析
    轮子来袭 vJine.Core 之 AppConfig<T>
    C# 数据类型映射 (SQLite,MySQL,MSSQL,Oracle)
    炫酷 2048 完全免费 色彩无线 流畅如飞
    DebugLog 打印方法执行时间
    [转] charles使用教程指南
    Macbook Pro配置PHP开发环境
    基于ubuntu 14搭建nginx+php+mysql环境
    Android Studio -修改LogCat的颜色
    [转]
  • 原文地址:https://www.cnblogs.com/SamllBaby/p/4702075.html
Copyright © 2011-2022 走看看