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

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

问题描述

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

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


运行时为每个COM对象创建一个RCW
,而不管
编号

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.

我的应用程序在自己的应用程序域中运行(它是Outlook插件),我想知道如果我使用Marshal .ReleaseComObject(x)在循环中,直到它的计数达到0(推荐)。它会释放来自其他加载项(在同一Outlook进程中的其他应用程序域中运行)的引用吗?

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)?

编辑:完美 - 现在的混乱甚至更大。基于2个答案(从Lette和Ilya),我们有2个不同的答案。官方 MSDN文档说明每个进程ver。2.0+),但缺少 ver。

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.

在同一时间,在Mason Bendixen的文章中,它说它是每个appdomain。

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

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

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.

感谢

推荐答案


在托管中,我们有一个每个应用程序域
cache
映射规范IUnknowns回
RCWs。当一个IUnknown进入
系统(通过元组调用,
通过激活,作为返回
参数从方法调用等),
我们检查缓存看到如果COM对象的RCW
已经存在。如果
存在映射,则返回对
现有RCW的引用。否则,将创建一个
新的RCW,并添加一个缓存映射

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.

http://blogs.msdn.com/mbend/rel =nofollow noreferrer> Mason的博客

from Mason's Blog

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

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