简体   繁体   English

COM +库应用程序的目的是什么?

[英]What's the purpose of COM+ library applications?

When a COM+ application is created the wizard offers to choose between a library and a server application. 创建COM +应用程序时,向导可以在库和服务器应用程序之间进行选择。

A server application is activated in a separate process and this can be used to cheaply interop 64-bit consumers with 32-bit in-proc COM components. 服务器应用程序在单独的进程中激活,这可以用于廉价地将64位使用者与32位进程内COM组件互操作。

What's the use of library applications that are activated right in the caller process? 在调用者进程中激活的库应用程序有什么用? Why use them instead of plain old in-proc COM servers? 为什么要使用它们而不是普通的旧进程内COM服务器?

There are several: 有几个:

  1. Performance - it is a bit faster as you don't have to go through the message automation (marshalling and unmarshalling) 性能 - 它更快一点,因为您不必经历消息自动化(编组和解组)

  2. Isolation - if many different Applications are using the Library, then each will have it's own copy. 隔离 - 如果许多不同的应用程序正在使用库,那么每个应用程序都将拥有它自己的副本。 This point is most important when dealing with the differences between an MTA (Multi Threaded Apartment) and a STA (Single Threaded Apartment Model) 在处理MTA(多线程公寓)和STA(单线程公寓模型)之间的差异时,这一点最为重要

THE IN-PROC Server (which is really an out of processes, out of the caller's process) is shared by all different callers (this is a great way to have cheap IPC/RPC) 所有不同的调用者共享IN-PROC服务器(实际上是一个进程外的,来自调用者的进程)(这是获得廉价IPC / RPC的好方法)

Ok I am editing with a few more definitions, and a bit more references: 好的我正在编辑一些更多的定义,以及更多的参考:

  1. Context is really all the state around the use of an object. Context实际上是围绕对象使用的所有状态。
  2. causality is really a thread like concept indicating the use of an object in a context. 因果关系实际上是一个概念,表示在上下文中使用对象。 ("A causality is a distributed chain of COM method calls that spans any number of contexts in any number of processes" - from ISBN: 0-201-61594-0) (“因果关系是COM方法调用的分布式链,跨越任意数量的进程中的任意数量的上下文” - 来自ISBN:0-201-61594-0)

Those to concepts are discussed in about 30 pages of chapter 2 from Tim Ewald's excellent book "Transactional COM+" ISBN: 0-201-61594-0 Tim Ewald的优秀着作“Transactional COM +”ISBN:0-201-61594-0将在第2章的大约30页中讨论这些概念。

So taking a direct quote from the summary of chapter 2: "An object can interact with its context using object context and with a given causality using call context. These two objects provide interfaces for interacting with COM+ runtime services. This style of coding, 'reaching into context' makes COM+ development very different from classic COM development." 因此,从第2章的摘要中直接引用:“一个对象可以使用对象上下文与使用调用上下文的给定因果关系进行交互。这两个对象提供了与COM +运行时服务交互的接口。这种编码风格,”进入上下文“使得COM +开发与传统的COM开发非常不同。”

Finally, Chapter 2 has a discussion "Why Library Applications?", (which is different from your question, Why not just plain old COM?) His arguments mainly indicate the same reasons from using a COM object, 1. Each application has it's own instance. 最后,第2章讨论了“为什么库应用程序?”,(与你的问题不同,为什么不只是普通的旧COM?)他的论点主要表明使用COM对象的相同原因,1。每个应用程序都有它自己的实例。 2. Load into non- DLLhost.exe process. 2.加载到非DLLhost.exe进程。 3. Much Less Overhead. 3.少开销。 4. Simple Deploy of common Objects. 4.简单部署常见对象。

So the bottom line is that if you are not Distributed, and Not Transactional In Nature, there may be no real advantage to using COM+ over COM. 所以最重要的是,如果你不是分布式的,而不是自然的事务性,那么使用COM +而不是COM可能没有什么好处。 But if you write a COM+ application and deploy it as a LIBRARY application, it will behave a little bit more like a COM component. 但是,如果您编写COM +应用程序并将其部署为LIBRARY应用程序,它将更像COM组件。

Hope that helps. 希望有所帮助。

The main purpose is to benefit from COM+ application contexts . 主要目的是从COM +应用程序上下文中受益。

CoGetObjectContext for IObjectContext or IObjectContextActivity will return E_NOTINTERFACE from pure in-process component, while it will successfully work in a COM+ library application (and a server application of course). CoGetObjectContextIObjectContextIObjectContextActivity将从纯在进程组件返回E_NOTINTERFACE,而这将成功地在一个COM +库应用程序(当然服务器应用程序)工作。

The security context is also available through CoGetCallContext for ISecurityCallContext . 安全上下文也可通过CoGetCallContextISecurityCallContext

It has nothing to do with performance or isolation. 它与性能或隔离无关。

As a site note, one way to check what's available to COM+ library applications is to run dcomcnfg.exe navigate to Component Services, Computers, My Computer, COM+ application, create a new library application and check what's still enabled (as opposed to a server application). 作为站点说明,检查COM +库应用程序可用内容的一种方法是运行dcomcnfg.exe导航到组件服务,计算机,我的电脑,COM +应用程序,创建新的库应用程序并检查仍然启用的内容(而不是服务器)应用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM