C# 使用SuperMap控件需要千万注意的地方,转载

}

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soGeometry);

_soGeometry = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soRecordset);

_soRecordset = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soDatasetVector);

_soDatasetVector = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_Dataset);

_Dataset = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soDatasets);

_soDatasets = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soDataSource);

_soDataSource = null;

System.Runtime.InteropServices.Marshal.ReleaseComObject(_soDataSources);

_soDataSources = null;

}

你没看错,其实我也很郁闷。这样写的确很弱,很委琐。

但是千万记住,如果不想你写的产品在你想不到的时候弹出“System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。”的错误,还是老实再老实的用这很弱的写法吧。

转载自http://www.gisbox.cn/thread-156-1-1.html