自定义GP工具创建的FeatureClass如何释放锁

自定义GP工具中创建了一个FeatureClass并写入数据,在最后执行了下面的过程释放了所有的资源,修改了ScemaLock为Share,但是还是不能删除生成的FeatureClass。
wsEdit.StopEditing(bSave);
IEnumSchemaLockInfo schemaLockInfo = null;
(fcOutput as ISchemaLock).GetCurrentSchemaLocks(out schemaLockInfo);
ISchemaLockInfo slinfo = null;
while ((slinfo = schemaLockInfo.Next()) != null)
{
if (slinfo.SchemaLockType == esriSchemaLock.esriExclusiveSchemaLock)
{
(fcOutput as ISchemaLock).ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
System.Diagnostics.Debug.WriteLine(string.Format("{0},{1},{2}", slinfo.SchemaLockType, slinfo.TableName, slinfo.UserName));
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(insertCursor);
System.Runtime.InteropServices.Marshal.ReleaseComObject(featBuffer);
System.Runtime.InteropServices.Marshal.ReleaseComObject(fcOutput);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wsEdit as IWorkspace);
已邀请:

朱新颖

赞同来自:

释放只是说程序内存中释放掉对该要素类的占用,并不能删除要素类本身,要素类是存放在gdb中的数据,如果想要删除,可以将IFeatureClass转为IDataset,然后执行IDataset.Delete

要回复问题请先登录注册