疑似 IDataStatistics 接口导致的 System.AccessViolationException异常

在程序中使用了 IDataStatistics 这个借口结果再次打开mdb数据的时候出现System.AccessViolationException异常。改为自己在循环中统计,则没有再出现异常。
哪位遇到过,或者是我的IDataStatistics接口使用方法不正确。哪位知道的请不吝赐教,谢谢!
==以下是调用接口的代码片段===
                    IFeatureCursor cursor = fc.Search(null, true);

                    ESRI.ArcGIS.Geodatabase.IDataStatistics dataStatistics = new DataStatistics();
                    dataStatistics.Cursor = cursor as ICursor;
                    dataStatistics.Field = codeFieldInDB;
                    System.Collections.IEnumerator enumerator = dataStatistics.UniqueValues;
                    enumerator.Reset();

                    IList<string> codeList = new List<string>();
                    while (enumerator.MoveNext())
                    {
                        codeList.Add(enumerator.Current.ToString());
                    }
                    ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(cursor);
已邀请:

nfc - GISer

赞同来自:

单独测试就没有问题,放到工程里面就报错,百思不得其解。但是报错的地方不是这里,有时候是在下一次打开mdb并OpenFeatureClass的时候

朱新颖

赞同来自:

应该是对mdb中要素类还有占用导致,释放IEnumerator试试。

要回复问题请先登录注册