运行时可调用包装(RCW)范围 - 进程或应用程序域? [英] Runtime callable wrapper (RCW) scope - process or application domain?

查看:219
本文介绍了运行时可调用包装(RCW)范围 - 进程或应用程序域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是运行时可调用包装(RCW)的范围,引用非托管COM对象时?根据文档:

  

运行时恰好创建一个RCW   每个COM对象不顾,则   存在的引用数   该对象。

如果我必须猜测 - 这样的解释应该是指每个过程中的一个,但真的是这样吗?任何额外的文件会非常欢迎的。

我的应用程序在其自己的应用领域(这是Outlook中的插件)运行,我想知道,如果我(X)在循环使用Marshal.ReleaseComObject的会发生什么,直到它的数为0(推荐)。它会释放其他加载项引用(在其他应用领域在同一展望进程中运行)?

编辑:完美的 - 现在的混乱是更大的。基于2个答案(由莱特和伊利亚),我们有2个不同的答案。官方 MSDN文档每个进程说,(对于版本。2.0+),但它缺少了这句话的版本。 1.1 DOC 的。

在同一时间,在梅森本迪克森的文章,它说,这是每个AppDomain。

由于他的文章是旧的(2007年4月),我给他发一封电子邮件,要求澄清,但如果别人有添加的东西,请你。

感谢

解决方案
  

在管理中,我们每个应用程序域有   高速缓存   映射规范IUnknowns回   的RCW。当一个IUnknown进入   系统(通过元帅呼吁,   通过激活,作为返回   从一个方法调用的参数等),   我们检查缓存如果RCW看   已经存在的COM对象。如果   映射存在,一个参考   现有RCW被返回。否则,   在创建新的RCW和一个高速缓存映射   被添加。

梅森的博客

What is the scope of Runtime Callable Wrapper (RCW), when referencing unmanaged COM objects? According to the docs:

The runtime creates exactly one RCW for each COM object, regardless of the number of references that exist on that object.

If I had to "guess" - this explanation should mean "one per process", but is it really? Any additional documentation will be very welcome.

My application runs in its own application domain (it is Outlook addin), and I would like to know what happens if I use Marshal.ReleaseComObject(x) in a loop until it's count reaches 0 (as recommended). Will it release references from other addins (running in other application domain in the same Outlook process)?

EDIT: Perfect - now the confusion is even bigger. Based on the 2 answers (from Lette and Ilya) we have 2 different answers. The official MSDN doc says per process (for ver. 2.0+), but it is missing this sentence for ver. 1.1 of the doc.

In the same time, in Mason Bendixen's article, it says it's per appdomain.

As his article is old (April 2007), I have send him an email asking for clarification, but if someone else has to add something, please do.

Thanks

解决方案

In managed, we have a per app domain cache mapping canonical IUnknowns back to RCWs. When an IUnknown enters the system (through a marshal call, through activation, as a return parameter from a method call, etc.), we check the cache to see if an RCW already exists for the COM object. If a mapping exists, a reference to the existing RCW is returned. Otherwise a new RCW is created and a cache mapping is added.

from Mason's Blog

这篇关于运行时可调用包装(RCW)范围 - 进程或应用程序域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆