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. COM
  4. Basic rule

Basic rule

Scheduled Pinned Locked Moved COM
comfunctionaltutorialquestion
6 Posts 2 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.
  • I Offline
    I Offline
    In At
    wrote on last edited by
    #1

    The basic rule of COM says, In COM, once you "publish" an interface contract by shipping a component, the contract is immutable—it cannot be changed in any way. You can not add. You can not delete. You can not modify. But, when you open Microsoft Word 97/98 and Microsoft Word 2000 's .OLB files, you will see that for extending the interfaces, they have added methods to the old interfaces. For example, in MS Word 2000 they have added methods in Application interface, and all the other interfaces. Why So? I feel the right approach is to add new interface if you want to extend an interface. Can somebody tell me its' reason??:confused:

    S 1 Reply Last reply
    0
    • I In At

      The basic rule of COM says, In COM, once you "publish" an interface contract by shipping a component, the contract is immutable—it cannot be changed in any way. You can not add. You can not delete. You can not modify. But, when you open Microsoft Word 97/98 and Microsoft Word 2000 's .OLB files, you will see that for extending the interfaces, they have added methods to the old interfaces. For example, in MS Word 2000 they have added methods in Application interface, and all the other interfaces. Why So? I feel the right approach is to add new interface if you want to extend an interface. Can somebody tell me its' reason??:confused:

      S Offline
      S Offline
      Shadi Al Kahwaji
      wrote on last edited by
      #2

      Hi, There are two ways to access a COM interface, accessing using virtual table (IUknown interface), and accessing using Dispinterface (IDispatch interface). If you are using the first approach, the fact that the interface is imutable is true, and you will have trouble in accessing changed interfaces. But if you are using the other approach, you are safe, becuase always you are accessing the same interface (IDispatch) which direct your call to the required interface. MS Office tools are using Automation (IDispatch interface), so they don't have problems in changing interfaces' methods. Regards, ShadiK. Shadi Al-Kahwaji

      I 1 Reply Last reply
      0
      • S Shadi Al Kahwaji

        Hi, There are two ways to access a COM interface, accessing using virtual table (IUknown interface), and accessing using Dispinterface (IDispatch interface). If you are using the first approach, the fact that the interface is imutable is true, and you will have trouble in accessing changed interfaces. But if you are using the other approach, you are safe, becuase always you are accessing the same interface (IDispatch) which direct your call to the required interface. MS Office tools are using Automation (IDispatch interface), so they don't have problems in changing interfaces' methods. Regards, ShadiK. Shadi Al-Kahwaji

        I Offline
        I Offline
        In At
        wrote on last edited by
        #3

        Hi, Thanks a lot for your information. In the application which I am writing, I support both dual and dispatch interface. Now, I want to publish a new version of my COM Server. How should I extend my existing interfaces? Thanks and Regards.

        S 1 Reply Last reply
        0
        • I In At

          Hi, Thanks a lot for your information. In the application which I am writing, I support both dual and dispatch interface. Now, I want to publish a new version of my COM Server. How should I extend my existing interfaces? Thanks and Regards.

          S Offline
          S Offline
          Shadi Al Kahwaji
          wrote on last edited by
          #4

          The most important thing that you don't change the current interfaces, in this way you have many options: 1. If your old interface name is IMyInterface, you might create a new one called IMyInterfaceEx which include the new functionality (within the same COM object) that you need to distribute. (This might be applicable if you have small added features) 2. You might create totaly new COM object on the same component (.DLL) which provide the new functionality plus the new interfaces, this new COM object can use the old COM object functionality in two ways, either by Containment or Aggregation, so the new clients for your component will deal with one COM object to access new and old functionality. 3. You might create totaly new COM component (.DLL) if you are providing very huage change to the old COM component. You have to read more about Containment and Aggregation, these are advanced topics in COM technology. Regards, ShadiK. Shadi Al-Kahwaji

          I 1 Reply Last reply
          0
          • S Shadi Al Kahwaji

            The most important thing that you don't change the current interfaces, in this way you have many options: 1. If your old interface name is IMyInterface, you might create a new one called IMyInterfaceEx which include the new functionality (within the same COM object) that you need to distribute. (This might be applicable if you have small added features) 2. You might create totaly new COM object on the same component (.DLL) which provide the new functionality plus the new interfaces, this new COM object can use the old COM object functionality in two ways, either by Containment or Aggregation, so the new clients for your component will deal with one COM object to access new and old functionality. 3. You might create totaly new COM component (.DLL) if you are providing very huage change to the old COM component. You have to read more about Containment and Aggregation, these are advanced topics in COM technology. Regards, ShadiK. Shadi Al-Kahwaji

            I Offline
            I Offline
            In At
            wrote on last edited by
            #5

            We have implemented COM automation server using MFC. MFC Use Nested Class approach to implement COM interface. What We have done is that for each component we have two interface IMyInterface and IDualMyInterface(for VB client) and both interface expose same set of function. IMyDualInterface is implemented in Nested class and IMyInterface is implemented in parent class. All the Call to IMyDualInterface Methods are routed to corrosponding IMyInterface implementation by using METHOD_PROLOGUE_EX Macro (This macro return the parent class pointer i.e.pThis). Now I have to Enhance my com server for this I have to make some changes in my both interface but according to COM rule I can not modify the interface once it is published, as it break the contract with my existing client that are using my previous COM server. I want to Know How I can Enhance my COM server that is using MFC support. regards.

            S 1 Reply Last reply
            0
            • I In At

              We have implemented COM automation server using MFC. MFC Use Nested Class approach to implement COM interface. What We have done is that for each component we have two interface IMyInterface and IDualMyInterface(for VB client) and both interface expose same set of function. IMyDualInterface is implemented in Nested class and IMyInterface is implemented in parent class. All the Call to IMyDualInterface Methods are routed to corrosponding IMyInterface implementation by using METHOD_PROLOGUE_EX Macro (This macro return the parent class pointer i.e.pThis). Now I have to Enhance my com server for this I have to make some changes in my both interface but according to COM rule I can not modify the interface once it is published, as it break the contract with my existing client that are using my previous COM server. I want to Know How I can Enhance my COM server that is using MFC support. regards.

              S Offline
              S Offline
              Shadi Al Kahwaji
              wrote on last edited by
              #6

              Create another two interfaces IMyInterfaceEx, IDualMyInterfaceEx which will expose the new fuctionality that you want to develop. IMyInterfaceEx implemenattion might be located on the same class which implements IMyInterface interface. And IDualMyInterfaceEx implemenattion might be located on the same class which implements IDualMyInterface interface. Regards, ShadiK. Shadi Al-Kahwaji

              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