English 中文(简体)
公寓在服务器的侧面,还是客户的侧面,在外处理环境中,是“住着”的吗?
原标题:Do apartments "live" on the server side or on the client side in a out-process environment?

我很难理解在外处理环境中的COM公寓。

Basically I can t understand why the client is required to call CoInitializeEx to register it s own thread in an apartment. I can understand object used by server threads and server threads living in STA or MTA. But I can t understand why the client should be concerned about this.

Every documentation/guide says the client has to call CoInitializeEx to register itself in an apartment. Does that mean that the server keeps tracks of client s threads? Or that the apartment data is allocated on the client process as well?

最佳回答

位于程序外服务器中的 COM 对象实际上由两部分组成—— 服务器中的执行代码和由编译者和 COM 运行时间创建的 RPC 代理/ 粘结代码。 调用远程 COM 对象可以转换为对本地代理对象的调用, 该代理对象然后使用某种 RPC 机制将调用该调用作为信息传送到服务器进程。 消息由服务器的根块选择, 然后调用真实的 COM 对象, 然后将结果传回代理, 然后解析它, 并返回到调用客户代码 。 从客户端和 COM 对象的角度来看, 所有的调用都是本地的, 即使像 DCOM 一样发生在网络上 。

现在客户的代理行为像正常的 COM 对象, 它必须居住在某种公寓中。 服务器中的 COM 对象也位于自己的公寓中。 COM 允许客户和服务器有不同的线条模型, 并处理适当的同步( 当两个相互操作的代码片处在不同的过程中时, 这一点就很容易了 ) 。

我建议你读读Process、Tread和Apartments 关于MSDN的COM指南的一部分,以便更好地了解什么是什么以及它们是如何相互联系的。

问题回答

它不是跟踪线条的服务器,而是将线条附加到某些公寓的COM。它也是拥有线条的客户,因此客户选择创建STA 或 MTA 。

一旦客户为线索选择了理想的公寓模式, COM将决定如何完全满足某些电话。 如果通信类只注册在 MTA 中运行, 而客户 steeda 是 STA, 那么通信部就有责任在工人 MTA 线上创建实际对象, 并将其界面连接到客户端 STA 中 。

客户端选择操作模式, COM 和服务器注册一起获得操作模式 。





相关问题
How can i add a button to all windows explorer instances?

I am trying to add a button to one of the existing tool bars in any windows explorer instance. After much research i figured out that BHO (browser helper objects) are the best way to hook to ...

Hunting memory leaks

I m finding leaked heap blocks by using the following command in WinDbg !heap –l With each leaked heap block I get, I m running to following to get the stack trace. !heap -p -a leakedheapblock The ...

Why use CComBSTR instead of just passing a WCHAR*?

I m new to COM. What exactly is the advantage of replacing: L"String" with CComBSTR(L"String") I can see a changelist in the COM part of my .NET application where all strings are replaced in this ...

IThumbnailProvider and IInitializeWithItem

I am trying to develop an IThumbnailProvider for use in Windows 7. Since this particular thumbnail would also be dependant on some other files in the same directory, I need to use something other than ...

Getting a byte array from out of process C++ COM to C#

What s the best way to get a chunk of memory (i.e. void*) from a COM server to C#? We have been using an IStream (using CreateStreamOnHGlobal) and passing that back, which worked. However when we ...

COM Basic links

folks can you provide me the tutorial link or .pdf for learning basic COM?. i do google it.. still i recommend answers of stackoverflow so please pass me.. Thanks

热门标签