为了账号安全,请及时绑定邮箱和手机立即绑定

发射一个方法疑问,懂得进来看看,高分求救!~

发射一个方法疑问,懂得进来看看,高分求救!~

斯蒂芬大帝 2018-12-07 08:03:10
bbb()方法 public string bbb(){            string result = "OK!";            string a = "1";            short i = 1;            axRFNCCTL1.Devices.get_Device(i).DataWrite(a + result, (short)(a.Length + result.Length));            return result;}   private void axRFNCCTL1_DataEvent(object sender, AxNRFCCTLCONTROLLib._IRFNCCTLEvents_DataEventEvent e)        {             string a = axRFNCCTL1.Devices.get_Device(e.devID).DeviceData.ToString();             setArray(a);            bbb();在和bbb()方法同一个程序里调用,这时调用bbb()方法有用。                    }     发射调用bbb()方法就没用了,不知道为什么 private object Invoke(string lpProcName, object[] va)        {            try            { // 载入程序集                 Type t = MyAssembly.GetType("DataLogic.Form1");                //Type[] type = MyAssembly.GetTypes();                //Type type = MyAssembly.                //foreach (Type t in type)                //{// 查找要调用的命名空间及类                     //if (t.Name == ClassName)                    //{// 查找要调用的方法并进行调用                         MethodInfo m = t.GetMethod(lpProcName);                        if (m != null)                        {                            if (s == false)                            {                                o = Activator.CreateInstance(t);                                s = true;                            }                             m.Invoke(o,va);                                                   }                        //else MessageBox.Show(" 装载出错 !");                    //}               // }            }//try             catch (System.NullReferenceException e)            {                MessageBox.Show(e.Message);            }//catch             return (object)0;         }                   /// <summary>        /// 取数据        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button1_Click(object sender, EventArgs e)        {            object[] strList = aaa.Trim().Replace("'", "").Split('*');            Invoke("bbb", strList).ToString(); 这里就是反射用bbb()方法        }
查看完整描述

2 回答

?
慕无忌1623718

TA贡献1744条经验 获得超4个赞

查看下线程ID,看是否在同一个线程里。

查看完整回答
反对 回复 2019-01-21
  • 2 回答
  • 0 关注
  • 424 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信