arcobjects开发中发现的问题

像arcobjects这种基于COM组件开发有时候遇到资源锁住的问题还是挺烦恼的。

今天工作中遇到的问题,搞了半天才解决。

在做拓扑脏区显示时候,图层以featurelayer的形式从mdb中加载的。所有工作完成后需要删除临时创建的topo数据库发现怎么都删除不了,检查了一遍又一遍确认所有资源都已经强制释放掉了然而mdb还是锁死状态。百思不得其解,最后还是通过查找帮助文档才发现的问题。

在图层清除的时候调用的IMap.clearlayers的方法,官方文档描述为:

ClearLayers removes all layers types from the Map.  ClearLayers does not change or reset the Map's spatail reference however.  In addition, ClearLayers does not affect any graphics stored in the Map's BasicGaphicsLayer - it's not a true Layer.  ClearLayers does not update the contents view (TOC) or the display.

而真正该去调用的应该是deletelayer。

DeleteLayer will automatically recalculate the Map's extent after the successful deletion of a layer.
Tips:
If a layer is selected in the TOC window ( IMxDocument::SelectedLayer), you can pass this to DeleteLayer.
When deleting a layer that references a feature class, like a FeatureLayer, executing  IDataLayer2::Disconnect will ensure that references to the feature class are cleared.

看来以前写法都不太对,平时遇到问题还是需要多看看帮助文档。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值