Deriving from TObject gives access error when exported to another dll


2004-05-01 04:03:50 AM
cppbuilder49
I have a dll which contains a base class that is derived from TObject. The
class is exported.
In my application I'm trying to derive another class from my base class. It
compiles fine, but when I try to create an instance of the class I get a
runtime error that says: Access violation at address 40003AD6 in module
'VCL50.bpl'. Read of address 676825B7.
The strange thing is that this works fine for classes that are not derived
from TObject. I can export those classes and use them as much as I want, but
as soon as I derive from TObject I get this error.
Examples of the exported classes in the dll:
// this generates an error when doing
// MyClass *pClass = new MyClass in the application
class __declspec(dllexport) MyClass : public TObject
{
public:
AnsiString sName;
AnsiString sData;
int __fastcall ReturnANumber();
AnsiString __fastcall ReturnAString();
__fastcall MyClass();
};
// this class works fine
class __declspec(dllexport) MyClass2
{
public:
AnsiString sName;
AnsiString sData;
int __fastcall ReturnANumber();
AnsiString __fastcall ReturnAString();
__fastcall MyClass2();
};
Any help would be greatly appreciated.
Mark Shirey