//选择连接的设备,USB口或 串口
        public void ChooseDevice() {
            //如果能读取机器的版本号,则不打开串口
            Timer timerUSB = new Timer();//创建一个Timer控件,实时读取数据
            timerUSB.Enabled = true;
            timerUSB.Interval = 1000;
            byte[] byteV = new byte[10];
            int VRet = MiReader.GetVersionNum(byteV);//读取设备版本号
            string strV = "";
            for (int i = 0; i < byteV.Length; i++)
            {
                strV += string.Format("{0:x2}", byteV[i]);
            }
            if (strV == "7265616465722d73667a")
            {
                timerUSB.Tick += new System.EventHandler(timerUSB_Tick);
            }
            //读取串口设备数据
            else
            {
                OpenSerialPort();
            }
        }
//USB口设备,循环读取设备数据
        private void timerUSB_Tick(object sender, EventArgs e)
        {
            byte[] byteuid = new byte[8];
            byte[] byteBuffer = new byte[8];            int nRet = MiReader.TYPEB_SFZSNR(26, 0, byteuid, byteBuffer);
            if (nRet != 0)
            {            }
            else
            {
                string strText = "";
                for (int i = 0; i < byteBuffer.Length; i++)
                {
                    strText += string.Format("{0:x2}", byteBuffer[i]);
                    strText = strText.ToUpper();
                }
                SendMess(strText.ToString());
            }
        }程序启动时,从两个设备中选取一个,如果设备版本号为‘7265616465722d73667a’,启用第一个设备,else启用第二个设备。
数据也能读取,但是不能点击程序的任何一个按钮,一点击就报‘System.StackOverflowException’。
望高手解决