Instead of overloads, can you just name them differently?
Well, I could, but I would like to keep my code consistent for my other .NET applications. I'm really just extending my classes to be available to COM and I would rather not add a whole bunch of functions that call my methods as one of my colleagues suggested...
i.e.
- <ComVisible(True)> _
-
Public Function Connect() As Boolean
-
'....blah
-
End Function
-
-
<ComVisible(True)> _
-
Public Function ConnectEx(ByVal Address As String) As Boolean
-
Return Connect(Address)
-
End Function
-
-
<ComVisible(False)> _
-
Public Function Connect(ByVal Address As String) As Boolean
-
'....blah
-
End Function
Because then when I call my class from .NET code, now I've got a whole bunch of irrelevant classes showing up. It's just ugly and I was looking for something more elegant.
It would be much nicer if I could just keep my regular overloaded functions in some manner but decorate them with some attribute described by:
- <ComVisible(True), ExposeAs("Connect")> _
-
Public Function Connect() As boolean
-
'....do stuff
-
End Function
-
-
<ComVisible(True), ExposeAs("ConnectEx")> _
-
Public Function Connect(ByVal Address As String) As Boolean
-
'....do other stuff
-
End Function
I obviously know that ExposeAs isn't a valid attribute...but is there not some attribute that explicitly defines the name by which a method is exposed to COM thus overriding the regular .NET method name?