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                 }

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

  • 相关阅读:
    excel 批量修改sql
    js select 改变当前选中option
    servlet 显示服务器上的图片
    @Security权限验证拦截参数
    签字 变成 图片 纯js+html实现
    web 的项目 搭乘war包,运行时候却找不到jar包
    jquery监听扫码枪获得值
    妹子的js 万一哪一天资源找不到了 记录下来
    react系列---【redux安装、创建仓库】
    react系列---【redux进阶】
  • 原文地址:https://www.cnblogs.com/SamllBaby/p/4702075.html
Copyright © 2011-2022 走看看