Interface inheritance with COM

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to implement two classes, one derived from the other, each of
which is based on an interface and make the whole thing visible to COM.
Here's what I have

public interface IMyBase
{
int Property1 { get; }
void Method1(int n);
}

[ClassInterface(ClassInterfaceType.None)]
public class MyBase : IMyBase
{
public int Property1 { get { /*implementation*/ } }
public void Method1(int n) { /*implementation*/ }
}

public interface IMyDerived : IMyBase
{
void Method2(int n);
}

[ClassInterface(ClassInterfaceType.None)]
public class MyDerived : IMyDerived
{
public void Method2(int n) { /*implementation*/ }
}

When I try to use this from a VB6 client, I can see MyBase properly. I can
also see MyDerived, but only 'Method2'. I cannot see the 'MyBase'
methods/properties from the MyDerived interface. I've tried a few variations
on the declaration of the MyDerived class, including:
public class MyDerived : MyBase, IMyDerived
to no avail.

Does anyone have any ideas how I can make the base interface
methods/properties available through the derived interface?

Thanks.
 
Does anyone have any ideas how I can make the base interface
methods/properties available through the derived interface?

Try it like this

public interface IMyDerived : IMyBase
{
new int Property1 { get; }
new void Method1(int n);
void Method2(int n);
}


Mattias
 
Thanks for the response. That works but it seems a bit clumsy. If I have a
few interfaces derived from the base then I have to duplicate the base
method/property declarations in all the derived ones?? There ought to be a
better way...

Ken
 
Back
Top