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                 }

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

  • 相关阅读:
    走进__proto__属性,看ie是否支持它,谁又来给他归宿
    如何安装zip格式的MySQL
    博客初心源于前端攻城狮
    Day 1: How to install jedi/codeintel plugin for sublime on Linux
    关于拓扑排序的一些想法
    POJ1061 青蛙的约会 __一维世界的爱情
    缩步查找法——一种新的查找算法
    HDU3371 Connect the Cities
    HDU1598 find the most comfortable road
    codeforces 349 div2.c
  • 原文地址:https://www.cnblogs.com/SamllBaby/p/4702075.html
Copyright © 2011-2022 走看看