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. C#: Fixed Function ID in COM DLL

C#: Fixed Function ID in COM DLL

Scheduled Pinned Locked Moved COM
csharpcomquestionannouncement
3 Posts 3 Posters 9 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.
  • D Offline
    D Offline
    DoxMan
    wrote on last edited by
    #1

    I have built a COM DLL with a number of functions in version 1: - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> second public function - DownloadPriceInfo_V2 --> third public function The COM DLL is called from an external application; the functions appear in the same order as shown above. In version 2, the DownloadProductInfo function has become obsolete, and needs to be replaced by V31 - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> becomes private - DownloadPriceInfo_V2 --> second public function - DownloadProductInfo_V31 --> third public function If I make the V2 function private (because it must no longer be used), the external application makes a shift in the code: all references to DownloadProductInfo_V2 are now replaced by references to the third public function, i.e. DownloadPriceInfo_V2 function. Is there any way I can give a fixed sequence number to the functions, so that I can avoid the shift? Or is there any other way to deal with this? Thank you.

    Dox Girl, where are you?

    Richard DeemingR F 2 Replies Last reply
    0
    • D DoxMan

      I have built a COM DLL with a number of functions in version 1: - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> second public function - DownloadPriceInfo_V2 --> third public function The COM DLL is called from an external application; the functions appear in the same order as shown above. In version 2, the DownloadProductInfo function has become obsolete, and needs to be replaced by V31 - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> becomes private - DownloadPriceInfo_V2 --> second public function - DownloadProductInfo_V31 --> third public function If I make the V2 function private (because it must no longer be used), the external application makes a shift in the code: all references to DownloadProductInfo_V2 are now replaced by references to the third public function, i.e. DownloadPriceInfo_V2 function. Is there any way I can give a fixed sequence number to the functions, so that I can avoid the shift? Or is there any other way to deal with this? Thank you.

      Dox Girl, where are you?

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Use the DispIdAttribute attribute[^] to specify the COM dispatch identifier for your methods and properties. That way, the order doesn't matter.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • D DoxMan

        I have built a COM DLL with a number of functions in version 1: - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> second public function - DownloadPriceInfo_V2 --> third public function The COM DLL is called from an external application; the functions appear in the same order as shown above. In version 2, the DownloadProductInfo function has become obsolete, and needs to be replaced by V31 - OnlineAvailCheck_V2 --> first public function - DownloadProductInfo_V2 --> becomes private - DownloadPriceInfo_V2 --> second public function - DownloadProductInfo_V31 --> third public function If I make the V2 function private (because it must no longer be used), the external application makes a shift in the code: all references to DownloadProductInfo_V2 are now replaced by references to the third public function, i.e. DownloadPriceInfo_V2 function. Is there any way I can give a fixed sequence number to the functions, so that I can avoid the shift? Or is there any other way to deal with this? Thank you.

        Dox Girl, where are you?

        F Offline
        F Offline
        F ES Sitecore
        wrote on last edited by
        #3

        As a side note, once interfaces are defined they should be fixed unless you are willing to re-compile all clients also. So if you want to alter the interface you should re-compile your client too. If you don't want to re-compile the client, then implement a new interface and have calls to your old interface redirect or forward to the method on the new interface. The redundant methods will just remain there, you can have them return errors if you want to indicate they shouldn't be called. Any new client, or client you don't mind re-compiling, will reference your new interface. This way all old and new clients still see the interfaces they were compiled against. You might be able to configure the interface forwarding for you automatically using the registry, it's been a while and back in the day interface forwarding was handled by the compiled and COM registration tools.

        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