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

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()方法
        }

斯蒂芬大帝
浏览 425回答 2
2回答

慕无忌1623718

查看下线程ID,看是否在同一个线程里。
打开App,查看更多内容
随时随地看视频慕课网APP