日期:2014-05-17  浏览次数:20862 次

本人写了一段代码访问ahci的内存,同一段代码不时会报出来一下错误。很困惑,求解
本帖最后由 shmily453397 于 2013-11-27 17:28:50 编辑
An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Drawing.dll
An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll

AccessViolationException was unhandled。Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Windows.Forms.dll

通过readAHCIInfo方法里面调用createTableData(),能得到结果(见附件)
但是界面显示一会后就会出现各种异常而导致界面崩溃。

 //step2 .创建方法跟委托相匹配的方法
        public void readAHCIInfo(int harddiskIndex)
        {
            Console.WriteLine("readAHCIInfo !!!!!!!!!!!!!!!");
            if (!this.dataGridView7.IsDisposed)
            {
                WinIO winIo = new WinIO(harddiskIndex);

                DataTable ahciData = winIo.createTableData();
                this.dataGridView7.DataSource = ahciData;
               
            }
        }

 private DataTable CreateTable()
        {
            // DataTable的名字
            DataTable dt = new DataTable("AHCI");
            //给DataTable定列名
            DataColumn dtColumn0 = new DataColumn();
            dtColumn0.ColumnName = "PortID";
            dt.Columns.Add(dtColumn0);          

            for (int index = 0; index < list_str.Count ; index++)
            {
                DataColumn dtColumn = new DataColumn();
                dtColumn.ColumnName = list_str[index];
                dt.Columns.Add(dtColumn);
            }