Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. COM problem urgent HELP needed

COM problem urgent HELP needed

Scheduled Pinned Locked Moved C / C++ / MFC
helpcomsysadmindata-structuresquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bill Wilson
    wrote on last edited by
    #1

    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

    E P N B 4 Replies Last reply
    0
    • B Bill Wilson

      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

      E Offline
      E Offline
      Ernest Laurentin
      wrote on last edited by
      #2

      Try this, it MAY solve your problem Add this BEFORE the COM_MAP of your Interface

      DECLARE_CLASSFACTORY_SINGLETON(CYourI1InterfaceClass)

      - Greatest invention : "The Microchip!"

      B 1 Reply Last reply
      0
      • E Ernest Laurentin

        Try this, it MAY solve your problem Add this BEFORE the COM_MAP of your Interface

        DECLARE_CLASSFACTORY_SINGLETON(CYourI1InterfaceClass)

        - Greatest invention : "The Microchip!"

        B Offline
        B Offline
        Bill Wilson
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • B Bill Wilson

          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

          P Offline
          P Offline
          pba_
          wrote on last edited by
          #4

          If you use ATL, Check CComModule::RegisterClassObject call. In your WinMain function , _Module.RegisterClassObject. Check the second parameter - is REGCLS_SINGLEUSE ? If is so , the class factory will be accesible only for one client at a time.

          1 Reply Last reply
          0
          • B Bill Wilson

            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

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • B Bill Wilson

              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

              B Offline
              B Offline
              Bill Wilson
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups