Is it possible to create single-instance assemblies?

  • Thread starter Thread starter Tim Long
  • Start date Start date
T

Tim Long

Can anybody tell me how I can ensure only a single instance of an assembly
is running on a given system at any given time?

To give an example, say I have an assembly "H" that provides hardware
abstraction and connects to a Comm port. Assebly H exposes two classes
H.ClassA and H.ClassB.

Different applications create instances of H.ClassA and H.ClassB. Both
applications need to run simultaneously and "H" needs to service both
applications using the same (shared) Comm port.

Obviously, there can only be one connection to the Comm port thus only a
single instance of my "H" assembly should execute.

Is there a way to do this in .NET or maybe I'm approaching the problem the
wrong way. Any ideas?

Regards,
--Tim Long
 
Jon, thanks for the reference, though it is subtly different from what I
want to do, so if you don;t mind I'd like to trouble you and/or the group to
consider the question again...

I do not want to prevent a second application from executing. On the
contrary, I require that multiple applications can access my shared objects.
What I need is a way of implementing a Singleton not just in the application
scope, but accross the entire system. This will ensure that both
applications receive the same instance of the shared assembly. I am reliably
informed that .exe COM servers work this way, but I don;t know how that
translates to .NET.

Regards,
Tim
 
Tim Long said:
Jon, thanks for the reference, though it is subtly different from what I
want to do, so if you don;t mind I'd like to trouble you and/or the group to
consider the question again...

I do not want to prevent a second application from executing. On the
contrary, I require that multiple applications can access my shared objects.
What I need is a way of implementing a Singleton not just in the application
scope, but accross the entire system. This will ensure that both
applications receive the same instance of the shared assembly. I am reliably
informed that .exe COM servers work this way, but I don;t know how that
translates to .NET.

I don't believe you can do that. What you would have to do instead is
have some way (remoting, perhaps?) of accessing the shared objects
indirectly.
 
I was coming around to the idea of remoting myself. It is a new concept to
me but my initial investigation seems to suggest this is the way to go. In
fact, there may be other advantages of using remoting such as being able to
relocate my hardware layer to a different host. The power of .NET continues
to astound me.

Thanks for taking the time to reply.

Regards,
--Tim
 
Back
Top