M
mats
Hi!
This is a quite involved question concerning two dll's that are consumed from a console application.
The first dll is called base.dll and is compiled in mixed mode (managed and unmanaged C++). One native class and one managed interface is declared and defined in base dll. The native class is exported via declspec(dllexport) and the managed interface via the public keyword. The managed interface has one property which returns a pointer to the unmanaged class. It looks like this:
// base.dll
// DLL_ITEM is defined as dllexport when base.dll is compiled
// and dllimport when some other dll imports it.
__nogc class DLL_ITEM Native
{
};
public __gc __interface NativeWrapper
{
__property Native* get_Native();
};
Now, base.dll is compiled and another dll, consumer1.dll, imports it.
In consumer1.dll two new classes are declared, one that implements the NativeWrapper interface and one that inherits from the Native class. To inherit from the native class, one must include its header file where it is declared. This is what is found in the consumer1.dll:
__nogc class Native2 : public Native
{
};
__gc class NativeWrapper2 : public NativeWrapper
{
__property Native* get_Native()
{
return new Native2();
}
}
Finally these two dll's are consumed in console.exe. Both base.dll and consumer1.dll are imported and console.exe compiles alright. But when consumer1.dll is loaded I get the following runtime error:
--
An unhandled exception of type 'System.TypeLoadException'
occurred in Unknown Module.
Additional information: Method get_Native in type
consumer1.Class1 from assembly consumer1, Version=1.0.1586.21893, Culture=neutral, PublicKeyToken=null does not have an implementation.
--
The reson for this seems to be the Native* return type which seems to be somewhat different between base.dll and consumer1.dll. If one changes Native* to void* everything works fine, no exception is thrown. So the question is, how can I use the Native class in both base.dll and consumer1.dll without getting the exception shown above?
I'm using VS .NET 2003.
/Mats
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
This is a quite involved question concerning two dll's that are consumed from a console application.
The first dll is called base.dll and is compiled in mixed mode (managed and unmanaged C++). One native class and one managed interface is declared and defined in base dll. The native class is exported via declspec(dllexport) and the managed interface via the public keyword. The managed interface has one property which returns a pointer to the unmanaged class. It looks like this:
// base.dll
// DLL_ITEM is defined as dllexport when base.dll is compiled
// and dllimport when some other dll imports it.
__nogc class DLL_ITEM Native
{
};
public __gc __interface NativeWrapper
{
__property Native* get_Native();
};
Now, base.dll is compiled and another dll, consumer1.dll, imports it.
In consumer1.dll two new classes are declared, one that implements the NativeWrapper interface and one that inherits from the Native class. To inherit from the native class, one must include its header file where it is declared. This is what is found in the consumer1.dll:
__nogc class Native2 : public Native
{
};
__gc class NativeWrapper2 : public NativeWrapper
{
__property Native* get_Native()
{
return new Native2();
}
}
Finally these two dll's are consumed in console.exe. Both base.dll and consumer1.dll are imported and console.exe compiles alright. But when consumer1.dll is loaded I get the following runtime error:
--
An unhandled exception of type 'System.TypeLoadException'
occurred in Unknown Module.
Additional information: Method get_Native in type
consumer1.Class1 from assembly consumer1, Version=1.0.1586.21893, Culture=neutral, PublicKeyToken=null does not have an implementation.
--
The reson for this seems to be the Native* return type which seems to be somewhat different between base.dll and consumer1.dll. If one changes Native* to void* everything works fine, no exception is thrown. So the question is, how can I use the Native class in both base.dll and consumer1.dll without getting the exception shown above?
I'm using VS .NET 2003.
/Mats
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...