当前位置: 首页 > news >正文

Release COM object

 

参考:http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx

 

This method is used to explicitly control the lifetime of a COM object used from managed code. You should use this method to free the underlying COM object that holds references to resources in a timely manner or when objects must be freed in a specific order.

The runtime callable wrapper has a reference count that is incremented every time a COM interface pointer is mapped to it. The ReleaseComObject method decrements the reference count of a runtime callable wrapper. When the reference count reached zero, the runtime releases all its references on the unmanaged COM object, and throws a System..::.NullReferenceException if you attempt to use the object further. If the same COM interface is passed more than once from unmanaged to managed code, the reference count on the wrapper is incremented every time and calling ReleaseComObject returns the number of remaining references.

 

private void ReleaseCOMObject(Object obj)

{

try

 

{

if (obj != null)

{

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

}

}

catch (Exception)

{

throw new Exception("Release COM object failed!");

}

finally

 

{

obj = null;

}

}

 

转载于:https://www.cnblogs.com/gracestoney/archive/2010/01/04/1638917.html

相关文章:

  • We do chicken right
  • 用sql语句修改表名和列名
  • squid网络服务的搭建和配置
  • 不能安装QQ2009SP6
  • 低成本云存储商冗余阵列 RAIC
  • DHCP和NIS
  • WF4.0 基础篇 (二十一) WorkflowInvoker
  • Lotus开发点滴
  • cisco switch 配置(vlan划分,生成树和高级生成树,高级特性,vlan路由)
  • 三层交换机配置DHCP的解决方案
  • 1年12个月13个情人节????
  • 生活中的定律——80/20法则
  • 每一个社区成员,用你的努力为微软平台的开发技术添上一把柴!
  • 你的新年期望是什么?
  • 招聘网站设计项目数据库设计
  • Angular4 模板式表单用法以及验证
  • ECMAScript入门(七)--Module语法
  • extract-text-webpack-plugin用法
  • java取消线程实例
  • k8s如何管理Pod
  • LeetCode18.四数之和 JavaScript
  • Linux快速复制或删除大量小文件
  • Python 使用 Tornado 框架实现 WebHook 自动部署 Git 项目
  • Python进阶细节
  • Python学习之路16-使用API
  • Webpack 4 学习01(基础配置)
  • 创建一种深思熟虑的文化
  • 大型网站性能监测、分析与优化常见问题QA
  • 模型微调
  • 学习Vue.js的五个小例子
  • 智能网联汽车信息安全
  • AI算硅基生命吗,为什么?
  • ionic入门之数据绑定显示-1
  • 阿里云移动端播放器高级功能介绍
  • ​总结MySQL 的一些知识点:MySQL 选择数据库​
  • # Python csv、xlsx、json、二进制(MP3) 文件读写基本使用
  • $redis-setphp_redis Set命令,php操作Redis Set函数介绍
  • (01)ORB-SLAM2源码无死角解析-(66) BA优化(g2o)→闭环线程:Optimizer::GlobalBundleAdjustemnt→全局优化
  • (C#)Windows Shell 外壳编程系列4 - 上下文菜单(iContextMenu)(二)嵌入菜单和执行命令...
  • (C++17) std算法之执行策略 execution
  • (C语言)字符分类函数
  • (day 2)JavaScript学习笔记(基础之变量、常量和注释)
  • (二)springcloud实战之config配置中心
  • (附源码)spring boot火车票售卖系统 毕业设计 211004
  • (数据结构)顺序表的定义
  • (算法设计与分析)第一章算法概述-习题
  • (一一四)第九章编程练习
  • (转) Android中ViewStub组件使用
  • (转)GCC在C语言中内嵌汇编 asm __volatile__
  • **CI中自动类加载的用法总结
  • ./include/caffe/util/cudnn.hpp: In function ‘const char* cudnnGetErrorString(cudnnStatus_t)’: ./incl
  • .class文件转换.java_从一个class文件深入理解Java字节码结构
  • .net core IResultFilter 的 OnResultExecuted和OnResultExecuting的区别
  • .Net CoreRabbitMQ消息存储可靠机制
  • .NET Framework 服务实现监控可观测性最佳实践