redoctober
Programmer
Hi all,
I have a question about inheritance when you get to deal with Interop. I'm building a library in C# (VS2003) which i later want to use in VB6 project. Generally i got it all working except for one thing that puzzles me. I have some basic inheritance in my C# classes. Something like this:
Basically, i create two interfaces A and B where B inherits A and then i create a class C that inherits interface B. Everything compiles fine, but when i try to use it in VB6 project and i create a variable of class C, the properties of the interface A are not accessible.
This code gives me Run-time error '438': "Object doesn't support the property or method" when i try to assign T.mA. Obviously the inheritance works differently in this case, but i can't figure out how. It seems like a textbook question but i can't seem to find the answer. Does anybody know how to do it properly?
I'd appreciate any help.
Eugene.
I have a question about inheritance when you get to deal with Interop. I'm building a library in C# (VS2003) which i later want to use in VB6 project. Generally i got it all working except for one thing that puzzles me. I have some basic inheritance in my C# classes. Something like this:
Code:
using System;
using System.Runtime.InteropServices;
namespace MyLib
{
[Guid("6C6B174A-32BA-4139-838C-DAB72831D7AF")]
public interface A
{
[DispId(1)]
int mA {set; get;}
}
[Guid("B5D7B4CF-49FE-403f-8E66-6919FB1901CA")]
public interface B:A
{
[DispId(2)]
int mB {set; get;}
}
[Guid("A5E0F4A2-5740-4d29-992C-31C6D0087E81")]
[ClassInterface(ClassInterfaceType.None)]
public class C:B
{
private int m_A;
private int m_B;
public int mA
{
get {return m_A;}
set {m_A = value;}
}
public int mB
{
get {return m_B;}
set {m_B = value;}
}
}
}
Basically, i create two interfaces A and B where B inherits A and then i create a class C that inherits interface B. Everything compiles fine, but when i try to use it in VB6 project and i create a variable of class C, the properties of the interface A are not accessible.
Code:
Dim T As MyLib.C
Set T = New MyLib.C
T.mA = 1
I'd appreciate any help.
Eugene.