Inherited methods not exposed to COM
I have an interface and class that I want to extend. So I created a new interface that inherits the original one. Then I create a new class that inherits the original class and implements the new interface. This way, the extended class should have all the original methods + the extended methods. I works fine in .NET. But when exposing this in a COM DLL the object browser in VB6 clearly shows that only the extended methods are available. The inherited methods are not.
Here is the original interface:
Imports System.Runtime.InteropServices
<ComVisible(True),
InterfaceType(ComInterfaceType.InterfaceIsDual)>
Public Interface IOriginal
Function OriginalFunction() As String
End Interface
And the original class:
Imports System.Runtime.InteropServices
<ComVisible(True),
ClassInterface(ClassInterfaceType.None)>
Public Class Original
Implements IOriginal
Public Function OriginalFunction() As String Implements IOriginal.OriginalFunction
Return "Original result"
End Function
End Class
And here is the extending interface:
Imports System.Runtime.InteropServices
<ComVisible(True),
InterfaceType(ComInterfaceType.InterfaceIsDual)>
Public Interface IAlternate
Inherits IOriginal
Function AlternateFunction() As String
End Interface
And class:
Imports System.Runtime.InteropServices
<ComVisible(True),
ClassInterface(ClassInterfaceType.None)>
Public Class Alternate
Inherits Original
Implements IAlternate
Public Function AlternateFunction() As String Implements IAlternate.AlternateFunction
Return "Alternate result"
End Function
End Class
How can I make this work like it should? I want VB6 to use the Alternate
class with both methods OriginalFunction
and AlternateFunction
. Right now, only AlternateFunction
is showing up as a valid function.
[update] I also tested class Alternate
with Implements IOriginal, IAlternate
to make sure the compiler would not overlook the IOriginal implementation. But that didn't change anything.