上面是我的代码,我在写该代码时就已经特别注意到了这一点,所以:m.Invoke(o,new object[]{"参数"}); 这里我使用了参数里面的 new object[]{} 里的内容就是参数的列表,比如要传递 1 和2 二个参数m.Invoke(o,new object[]{1,2});接收方也设置成相应的2个参数就可以了此文原文贴在CSDN 的文档区你可以去找找

解决方案 »

  1.   

    你的方法我试了。。总是报错"Web_Sn_Extend_Library.dll" Error: 未找到方法 Web_Sn_Extend_Library.Extend_Library.method1
      

  2.   

    ArLi2003(阿利 来的少了我还会爱你们的) ( ) 信誉:100 回答一下呗
      

  3.   

    如果方法的返回值是string []类型的怎么处理呢???? private string[] Retrun_Register_Info(string interrogate)
    {
    string [] Key_Array =new string[4]; string HD = “null“ ;
    string Newy = “null“ ;
    string Newn = “null“ ;
    string Ody = “null“ ;
    string Odn = “null“ ; Key_Array[0] = HD ;
    Key_Array[1] = Newy ;
    Key_Array[2] = Newn ;
    Key_Array[3] = Ody ;
    Key_Array[4] = Odn ; return Key_Array;

    }
      

  4.   

    我好久没来了,不好意思你可以改一下该类,如下return m.Invoke(o,new object[]{"参数"}); 它支持返回值(object 装箱)如果还是不会那么用这个吧:http://www.zpcity.com/ArLi//commonprj/cls_LoadDll.cs用法比如:object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack(string DLL文件名, string 命名空间, string 类名, string 方法名, object[] 参数)然后比如该方法返回的是 string 型就可以if (rs != null) string s = (string)rs;
      

  5.   

    object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack(string DLL文件名, string 命名空间, string 类名, string 方法名, object[] 参数)里包含了各参数的类型,真正用起来应该是:object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack(DLL文件名, 命名空间, 类名, 方法名, 参数)
      

  6.   

    比如你有个DLL 名叫 dll1.dll,命名空间是 mydll,类名叫 dllclass,方法是public int getmyint(int x, int y) {
      return x+y;
    }那么就如下操作,先下载 http://www.zpcity.com/ArLi//commonprj/cls_LoadDll.cs,然后将它加到你的工程中(解决方案管理器中添加已存在项),然后使用它:object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack("dll1.dll", "mydll", "dllclass", getmyint, new object[]{1,2});if (rs != null) {
     if (obj.GetType() == typeof(string)) {
      MessageBox.Show("错误:" + (string)rs);
     } 
     else if (obj.GetType() == typeof(int)) {
      //正常返回值
      int i = (int)rs;
      //TODO: 你的操作
     }
    }
      

  7.   

    其中object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack("dll1.dll", "mydll", "dllclass", getmyint, new object[]{1,2});忘记加引号了,应为:object rs = ArLi.CommonPrj.cls_LoadDll.LoadAndRunMethodWith_ObjectBack("dll1.dll", "mydll", "dllclass", "getmyint", new object[]{1,2});