COM problem urgent HELP needed
-
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2. I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes. Is it possible to do this so only one A.exe is launched? If so, how? We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Thanks for the help, Bill
-
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2. I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes. Is it possible to do this so only one A.exe is launched? If so, how? We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Thanks for the help, Bill
Try this, it MAY solve your problem Add this BEFORE the COM_MAP of your Interface
DECLARE_CLASSFACTORY_SINGLETON(CYourI1InterfaceClass)
- Greatest invention : "The Microchip!"
-
Try this, it MAY solve your problem Add this BEFORE the COM_MAP of your Interface
DECLARE_CLASSFACTORY_SINGLETON(CYourI1InterfaceClass)
- Greatest invention : "The Microchip!"
I tried it, but it didn't help. I think its because there are two apps accessing two different interfaces, rather than two apps accessing the same interface. Next attempt is to use CoGetClassObject. MSDN says: "Provides a pointer to an interface on a class object associated with a specified CLSID. CoGetClassObject locates, and if necessary, dynamically loads the executable code required to do this." Sounds like it won't load the EXE if it's already there. This coincides with VB and GetObject versus CreateObject. Unfortunately I get an error AND the wrong effect:
hr = CoGetClassObject(ID, CLSCTX_LOCAL_SERVER, NULL,
IID_IDispatch, (void **)&(m_pBroker));
if(hr = S_OK)
{
g_pErrorLog->LogError(4,"Get Class succeeded " + strObjName,_strModule);
} else {hr = CoCreateInstance(ID, NULL, CLSCTX\_LOCAL\_SERVER, IID\_IDispatch, (void \*\*)&(m\_pBroker)); g\_pErrorLog->LogError(4,"Try to CoCreate",\_strModule);
}
When it executes the CoGetClassObject call, I get an ERROR_NO_INTERFACE message 0x80004002. AND a second .EXE is loaded. :(( Thanks for the help, Bill
-
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2. I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes. Is it possible to do this so only one A.exe is launched? If so, how? We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Thanks for the help, Bill
-
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2. I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes. Is it possible to do this so only one A.exe is launched? If so, how? We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Thanks for the help, Bill
Have you considered using the GIT or ROT? Singleton won't work because S1 and S2 are seperate processes any data in A won't be shared. Bill Wilson wrote: We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Ah, testing.
-
I have a COM server (A.exe) it supports two interfaces I1 and I2. I also have two services S1.exe and S2.exe. S1 creates and instance of I1 and S2 creates an instance of I2. I expected to find only one A.exe running. Instead I find two. This is a problem for two reasons. S2 must release and recreate the interface regularly, causing the initialization of A.exe to happen way too often. The other issue is that I2 and I1 share a global array (protected by a MUTEX). This sharing clearly won't work if there are two separate eA.exes. Is it possible to do this so only one A.exe is launched? If so, how? We are supposed to release this today. The cyclic creation and destruction of a second A.exe was just observed for the first time today. Thanks for the help, Bill
Solon's suggestion put me on the right track. There are 3 modes in which to register: REGCLS_SINGLEUSE (obvously wrong) REGCLS_MULTIUSE (I ghought this one would work for me) REGCLS_MULTI_SEPARATE (Its THIS ONE!!) This is the one to use if you want multiple clients to share the same instance of the server. The use of the word SEPARATE fooled me into not realizing that if I wanted them to use the same server, I should use the SEPARATE option. :-D lol. Thanks for the help, Bill