Marshal.ReleaseComObject 释放COM对象
.NET的垃圾收集机制不负责回收COM对象,因此要手动对COM对象进行回收,可采用.NET提供的Marshal对象的ReleaseComObject和FinalReleaseComObject来解决。
其中,ReleaseComObject
Decrements the reference count of the supplied runtime callable wrapper.
FinalReleaseComObject:
Releases all references to a runtime callable wrapper (RCW) by setting the reference count of the supplied RCW to 0.
具体参见以下链接:
微软Marshal.ReleaseComObject 方法的来龙去脉
ESRI Developer Network--How to release COM references