Markus Ewald
2008-01-17 07:26:37 UTC
Hi!
I've got a COM Interop library written in C#, .NET 2.0. This library
exposes a COM class which implements two interfaces, one interface comes
from an imported VB6 class library (CHelloWorld) and another is declared
in C# itself (CExtendedHello).
If I attempt to use this COM class via late binding (IDispatch) in VB6,
the following happens:
Dim o As Object
Set o = CreateObject("ManagedInteropHello.CExtendedHello")
Call o.Hello ' Doesn't work!
Call o.HelloUser("TestApplication")
I can only call the HelloUser() method that is in the default interface
of the class. But watch what happens if cast this class to CHelloWorld
and back:
Dim hw As HelloWorldLib.CHelloWorld
Set hw = o
Set o = hw
Call o.Hello
Call o.HelloUser("TestApplication") ' Doesn't work!
Now the Hello() method from the CHelloWorld interface works and the
HelloUser() method from the default interface ceases to exist.
Its as if there were two completely seperate IDispatch interfaces for
the class.
Can someone explain this?
What I'm trying to do is give the class a single IDispatch interface
that contains all methods of all interfaces.
-Markus-
I've got a COM Interop library written in C#, .NET 2.0. This library
exposes a COM class which implements two interfaces, one interface comes
from an imported VB6 class library (CHelloWorld) and another is declared
in C# itself (CExtendedHello).
If I attempt to use this COM class via late binding (IDispatch) in VB6,
the following happens:
Dim o As Object
Set o = CreateObject("ManagedInteropHello.CExtendedHello")
Call o.Hello ' Doesn't work!
Call o.HelloUser("TestApplication")
I can only call the HelloUser() method that is in the default interface
of the class. But watch what happens if cast this class to CHelloWorld
and back:
Dim hw As HelloWorldLib.CHelloWorld
Set hw = o
Set o = hw
Call o.Hello
Call o.HelloUser("TestApplication") ' Doesn't work!
Now the Hello() method from the CHelloWorld interface works and the
HelloUser() method from the default interface ceases to exist.
Its as if there were two completely seperate IDispatch interfaces for
the class.
Can someone explain this?
What I'm trying to do is give the class a single IDispatch interface
that contains all methods of all interfaces.
-Markus-