gpt4 book ai didi

.net - 运行时可调用包装器 (RCW) 范围 - 进程域还是应用程序域?

转载 作者:行者123 更新时间:2023-12-04 14:53:31 25 4
gpt4 key购买 nike

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

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



如果我必须“猜测”——这个解释应该意味着“每个进程一个”,但真的是这样吗?非常欢迎任何其他文件。

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

编辑:完美 - 现在困惑更大了。基于 2 个答案(来自 Lette 和 Ilya),我们有 2 个不同的答案。官方 MSDN doc表示每个进程(适用于 2.0+ 版),但 ver. 1.1 of the doc 缺少这句话.

同时,在 Mason Bendixen 的文章中,它说它是每个应用程序域。

由于他的文章很旧(2007 年 4 月),我给他发了一封电子邮件,要求澄清,但如果其他人必须添加一些内容,请添加。

谢谢

最佳答案

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.



来自 Mason's Blog

关于.net - 运行时可调用包装器 (RCW) 范围 - 进程域还是应用程序域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/159313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com