需要共享属性跨我的COM服务器的实例 [英] Need shared property accross instances of my COM server

查看:123
本文介绍了需要共享属性跨我的COM服务器的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有共享属性的VB.NET COM类,如ABC。问题是组件被几个C ++ COM exe使用,所以它的我的理解,他们每个将获得自己的组件加载,并且Shared属性将是每个EXE的唯一。有没有办法得到这个程序集的交叉EXE共享属性?



Tx。

解决方案

通过创建一个进程外的COM服务器(通常也被称为ActiveX EXE),你所描述的内容将是容易地在本地COM中实现的。顾名思义,进程外COM服务器在其自己的进程中运行,并通过COM接口为其提供方法。如果多个客户端同时使用COM服务器,则它们都共享相同的服务器进程,因此该进程内的所有全局数据都在所有客户端之间共享。



不幸的是。 NET不提供任何用于创建进程外COM服务器的机制。所有COM可见的.NET程序集都作为进程内的COM库,所以每个使用它的客户端在自己的进程中都有自己的一组全局数据。



唯一的选择是创建一个标准的进程内COM可见库,但它只是一个传递包装器,呼吁一些其他过程。 .NET中的进程间通信通常使用WCF进行处理,因此典型的解决方案是在后端运行WCF服务,COM可见库与其通信。如果你不想使用WCF,你还可以看看.NET Remoting或原始TCP / IP套接字。



这里有一个鸡 - 划痕图,我的意思是:



p>

I have a VB.NET COM class with a Shared property, like ABC. The problem is the component is used by several C++ COM exe, so its my understanding that they each will get their own assembly load, and the Shared property will be unique to each EXE. Is there a way to get for this assembly a cross EXE shared property ?

Tx.

解决方案

What you are describing would be "easily" accomplished in native COM by creating an out-of-process COM server (also commonly referred to as an ActiveX EXE). As the name implies, an out-of-process COM server runs in its own process and serves it's methods via a COM interface. If multiple clients use the COM server simultaneously, they both share the same server process, so any global data within that process is shared between all of the clients.

Unfortunately, .NET does not provide any mechanism for creating an out-of-process COM server. All COM visible .NET assemblies act as in-process COM libraries, so each client using it has it's own set of global data within their own processes.

The only alternative is to create a standard in-process COM-visible library, but have it just be a pass-through wrapper which calls out to some other process. Inter-process communication in .NET is typically handled with WCF, so the typical solution would be to have a WCF service running in the back-end with which the COM-visible library communicates. If you don't want to use WCF, you could also look at .NET Remoting or raw TCP/IP sockets.

Here's a chicken-scratch diagram to help visualize what I mean:

这篇关于需要共享属性跨我的COM服务器的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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