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                 }

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

  • 相关阅读:
    List of the best open source software applications
    Owin对Asp.net Web的扩展
    NSwag给api加上说明
    'workspace' in VS Code
    unable to find valid certification path to requested target
    JMeter的下载以及安装使用
    exception disappear when forgot to await an async method
    Filter execute order in asp.net web api
    记录web api的request以及response(即写log)
    asp.net web api的源码
  • 原文地址:https://www.cnblogs.com/SamllBaby/p/4702075.html
Copyright © 2011-2022 走看看