Connecting Tech Pros Worldwide Forums | Help | Site Map

Using DLL from Unmanaged Code : Unable to access parent interface members

Maansi Sanghi
Guest
 
Posts: n/a
#1: Nov 17 '05
Hello,

(1) I am building a com component with multiple interfaces in .NET Managed
VC++
(2) Then use the managed .NET dll in unmanaged code after registering
through regasm and getting the tlb file

Problem:
(A) Everyrthing works fine except that I get a compile time error C2039
while trying to
ACCESS PARENT INTERFACE's MEMBER function

(B) I notice that the tlh file created does not contain the parent
interface's member functions in the child
interface

CODE FOR .NET MANAGED DLL
namespace ClassLibrary1
{
public __gc __interface IBaseInterface
{
public:
virtual void func1(); //parent interface's member function
};

public __gc __interface IChildInterface: public IBaseInterface
{
public:
virtual void func2(IChildInterface* pChild); //child interface member
function
};

[ClassInterface(ClassInterfaceType::AutoDual)]
public __gc class Class1: public IChildInterface
{
virtual void func1() { } //implementation for IBaseInterface::func1
virtual void func2(IChildInterface* pChild) //implementation for
IChildInterface::func2
{
pChild - > func1(); //NO ERROR while accessing
parent interface member here
}
};

};

CLIENT CODE:
{
IChildInterfacePtr child;
HRESULT hr = child.CreateInstance(__uuidof(Class1));
child - >func2(); //OK
child - >func1( child ); //ERROR
}

Error
error C2039: 'func1' : is not a member of 'IChildInterface'
ClassLibrary1.tlh(161) : see declaration of ''IChildInterface'


Regards,
Maansi




Closed Thread