Getting a link in .net code to an already running process

Is it possible in managed code to get a reference to an already running process (COM + component) and call methods on it? Instead of instantiating a new object, there is a way to point to an already running instance of a COM object so that the .net code has a reference to the running process just as if it had created it - to call methods on it as if it had injected a new one into its own application domain?

0


a source to share


1 answer


COM

It all depends on the COM component. If it's designed to be singleton (this is supported directly in ATL, for example) and it doesn't work, then getting the same object is the only option.

On the other hand, most COM components do not provide this capability, even if they do not work. A singleton broker / proxy component can be owned by one instance of the component in question.



Summary: This can be done, but only in collaboration with the component, the client code "creates an instance" by overriding that instance to return the same object.

WCF

WCF might be a different route. By default, the WCF Server Runtime will instantiate a new instance for each call. But you can use attributes to override this and serve all client requests in one instance (and you have to handle concurrency). Equally, a class that implements a service contract can refer to a singleton.

0


a source







All Articles