我在子窗体中的UDP初始化通讯什么的都没问题,唯独在主窗体中,加入如下这句话就不行:
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(glocalIPAddress), 12345);//应用端口
加入后,debug时窗体还未等全部显示完成就退出了,找不出问题。
下面提示信息为:
程序“[0x4218] StrapControl.exe”已退出,返回值为 -1073741819 (0xc0000005) 'Access violation'。
按这个信息搜了下,网上的解决办法不适合我的现象。求解!

解决方案 »

  1.   

    现在看来好像又与读取Access库有关了,太怪异了!
                try
                {
                    DataSet ds1 = Accdb_Opr.GetDataTableFromCurDB("select * from 基本信息 ");
                    if (ds1.Tables[0].Rows.Count > 0)//代表库中有数据
                    {
                        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                        {
                            STRP_stu strp_stu = new STRP_stu();
                            strp_stu.HostDevice = new byte[100, 200];                        strp_stu.GroupName = ds1.Tables[0].Rows[i]["皮带编号"].ToString();
                            strp_stu.GroupIP = ds1.Tables[0].Rows[i]["IP地址"].ToString();                        DataSet ds2 = Accdb_Opr.GetDataTableFromCurDB("select distinct 主机号 from 皮带信息 where 皮带编号='" + strp_stu.GroupName + "'");
                            for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                            {
                                strp_stu.HostDevice[j, 0] = Convert.ToByte(ds2.Tables[0].Rows[j]["主机号"].ToString());                            DataSet ds3 = Accdb_Opr.GetDataTableFromCurDB("select distinct 终端号 from 皮带信息 where 皮带编号='" + strp_stu.GroupName + "'and 主机号 =" + strp_stu.HostDevice[j, 0]);                            for (int k = 1; k < ds3.Tables[0].Rows.Count; k++)//第0位是主机号,所以从第1位开始。
                                {
                                    strp_stu.HostDevice[j, k] = Convert.ToByte(ds3.Tables[0].Rows[k]["终端号"].ToString());
                                }
                            }
                            lstSTRP.Add(strp_stu);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
    现在,这段代码打开也不行了,原来是好用的。