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

COM & VB.NET overloading

Scheduled Pinned Locked Moved COM
databasetutorialquestioncsharp
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.
  • 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) (K)

    H J 2 Replies 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) (K)

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Because overloading isn't supported in COM, hence a COM-Callable Wrapper (CCW) can't be created properly. Choose one or the other, but not both.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      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) (K)

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        What's the VARIANT equivalent type? -- You're entertaining at least.

        N 1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          What's the VARIANT equivalent type? -- You're entertaining at least.

          N Offline
          N Offline
          Niels Penneman
          wrote on last edited by
          #4

          object greetz ;-) *Niels Penneman*


          Software/Dev Site
          Personal Site


          J 1 Reply Last reply
          0
          • N Niels Penneman

            object greetz ;-) *Niels Penneman*


            Software/Dev Site
            Personal Site


            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #5

            Is this always true: object <=> VARIANT? :~ -- I am perpetual, I keep the country clean.

            N 1 Reply Last reply
            0
            • J Jorgen Sigvardsson

              Is this always true: object <=> VARIANT? :~ -- I am perpetual, I keep the country clean.

              N Offline
              N Offline
              Niels Penneman
              wrote on last edited by
              #6

              If you don't know what type, and specify none, the default is Object, in non-.NET VB (:-)) that was Variant. However, do not convert "As Any" in API declaratioins to "As Object", because you'll get an error like "not set to an instance of an object"..., use the most convenient type instead, if you are using more of them, define different functions referring to the same alias ;-) greetz ;-) *Niels Penneman*


              Software/Dev Site
              Personal Site


              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