PDA

Click to See Complete Forum and Search --> : Share same class instance between applications


Edneeis
Jul 18th, 2002, 01:02 PM
With VB6 you could make an activeX exe and set its threadpool to 1 and with a bit of luck share the same instance of a class even in different applications, what is the .NET equviliant? I know I can use shared properties and what not to share parts of a class across mulitple instances of the class, but that only works if they are in the same application. I am figuring that what made the old activex exe trick work is the fact that it was out-of-process. So is there a way to make out of process components in .NET? Or can I use a windows service to share the class?

Matt02
Jul 26th, 2002, 04:29 PM
Now I'm not sure exactly what this activex trick accomplishes because I've never used it, but sharing an instance of a class between applications is what .net remoting is all about. Its kind of involved but what you do is create a class and compile it into a dll then import it into a server application and a client application. If you set the class in the server to be a singleton SAO (wow, I never realized how lame that sounds) then the same class is exposed to all clients that connect. In the server you can have SAO and CAO objects, each of which can be singleton or single cell. SAO is server activated objects, this means that the server creates the object and maintains it for its lifetime (which is by default 5mins), CAO are client activated objects, these are created for each user that connects. Singleton objects are shared among all users and single cell objects are unique to each user. And it really keeps going on without explaining a hell of a lot. To summarise there are a lot of features in .net remoting and you need to read a guide if you want to actually use it. I recommend you go to http://www.microsoft.com/seminar/ and under "developer" you will find a seminar called "Develop Distributed Applications using Microsoft® .NET Remoting" this is a really good intro to .net remoting and you dont have to read anything (which is a big plus to me), it also has some demos that clearly show the differences between the different objects.

SoCalled
Jul 26th, 2002, 04:36 PM
From what l understand, and point out if l'm wrong, you can used the Empty App option to build the class dll, or a web services. We're trying out the Empty App thingy at the moment.

Matt02
Jul 26th, 2002, 04:43 PM
Yep, thats how I did it.
:)