COM+ singleton ?
-
Hy everybody, Please help me with an ideea. The problem is simple, but the solution... In fact, i need to have only one permanent instance of an ATL COM+ object (or more but only persistent public data members), and 3 or more clients who must connect at this COM object to get and put data. The clients are C++ who connect with CreateInstance and ASP who use CreateObject. The problem is at each new CreateInstance of a new client, in COM+ appear a new instance of my COM+ object, even i use DECLARE_CLASSFACTORY_SINGLETON. Even if i use the both threading model, in any apartments, the public data look to be the same only to C++ clients, a new ASP instance will create a new object with new different public memebers !!! Adrian Bacaianu
-
Hy everybody, Please help me with an ideea. The problem is simple, but the solution... In fact, i need to have only one permanent instance of an ATL COM+ object (or more but only persistent public data members), and 3 or more clients who must connect at this COM object to get and put data. The clients are C++ who connect with CreateInstance and ASP who use CreateObject. The problem is at each new CreateInstance of a new client, in COM+ appear a new instance of my COM+ object, even i use DECLARE_CLASSFACTORY_SINGLETON. Even if i use the both threading model, in any apartments, the public data look to be the same only to C++ clients, a new ASP instance will create a new object with new different public memebers !!! Adrian Bacaianu
-
Hy everybody, Please help me with an ideea. The problem is simple, but the solution... In fact, i need to have only one permanent instance of an ATL COM+ object (or more but only persistent public data members), and 3 or more clients who must connect at this COM object to get and put data. The clients are C++ who connect with CreateInstance and ASP who use CreateObject. The problem is at each new CreateInstance of a new client, in COM+ appear a new instance of my COM+ object, even i use DECLARE_CLASSFACTORY_SINGLETON. Even if i use the both threading model, in any apartments, the public data look to be the same only to C++ clients, a new ASP instance will create a new object with new different public memebers !!! Adrian Bacaianu
It looks like you want a system-wide singleton (accross process boundaries). You would indeed get funny results with this approach: - different processes (in your example: IIS and the C++-application) instanciating your component would get a singleton *per process*. - any static data you maintain dies when your dll goes out of memory: this happens if all interfaces are released: DLLCanUnload is called on a regular basis, and when it returns true (default ATL-implementation: when all reference counts are zero), the dll is unloaded. You can solve this problem by leaving the COM-singleton for what it is, designing your component as a multiply instantiatable component and using either static data in a persistent, out-of-process server (take a look at ATL-service) or simply persist your data in a database.