Danra
Danra

Reputation: 9906

How to implement a singleton .NET component, for use by multiple processes?

I would like to implement a component in .NET, and consume it in COM-aware clients via COM interop.

I would like this component to be a singleton across all processes that use it.

This thread suggests using WCF/remoting but doesn't go into much detail. Is there a good reference/example?

Upvotes: 4

Views: 252

Answers (2)

jgauffin
jgauffin

Reputation: 101140

Why not create a windows service that the COM component communicates with? The COM is the interface that all your users work with while the service contains the actual logic.

Upvotes: 0

Aliostad
Aliostad

Reputation: 81660

Remoting is a relic of the past and has been replaced by WCF.

You need to implement a WCF service and set the instancing mode to Single.

I suggest you expose it as a Named Pipe service and host it on Windows service. A word of caution, however, if it starts giving you problems with Named Pipe hardening, you might have to use TCP binding.

Upvotes: 4

Related Questions