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. Visual Basic
  4. VB.NET overloading & COM

VB.NET overloading & COM

Scheduled Pinned Locked Moved Visual Basic
databasetutorialquestioncsharp
2 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
    izotov
    wrote on last edited by
    #1

    Hi, I'm working on a VB.NET project and my objects should be reachable using COM. My problem is that these objects have overloaded methods, properties, which seems problematic. For example I have a collection class with two item properties: Default Public ReadOnly Property Item(ByVal Key As String) As Object and Default Public ReadOnly Property Item(ByVal Index As Integer) As Object When I try to use an object of this class in a COM only environment - like MS Word - there only one Item can be seen, and allways the first. So using the order above I can query collection items only by Key, when I change the order I can query only by Index. This problem does not occour under .NET. My question is: how to do VB.NET overriding, polymorphism to satisfy COM requirements? (K)

    M 1 Reply Last reply
    0
    • I izotov

      Hi, I'm working on a VB.NET project and my objects should be reachable using COM. My problem is that these objects have overloaded methods, properties, which seems problematic. For example I have a collection class with two item properties: Default Public ReadOnly Property Item(ByVal Key As String) As Object and Default Public ReadOnly Property Item(ByVal Index As Integer) As Object When I try to use an object of this class in a COM only environment - like MS Word - there only one Item can be seen, and allways the first. So using the order above I can query collection items only by Key, when I change the order I can query only by Index. This problem does not occour under .NET. My question is: how to do VB.NET overriding, polymorphism to satisfy COM requirements? (K)

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      COM can't expose overloaded methods through Automation - it's not part of the specification. The .NET Framework selects one of the method overloads to be exposed to COM. I think you can select a different overload to be exposed by using the ComVisibleAttribute attribute to hide the ones you don't want COM/Automation clients to see. The other alternative is to give each overload a unique name (removing the overloads).

      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