"as" operator across DLLs
Posted on 1999-11-09
It looks like the "is" and "as" operators do not work across DLLs.
I have an object created in one DLL. For example TStrings.
I pass this object via exported function or a COM interface method to another DLL.
function GetTheObject() : TObject; external; (or TStrings actually - it doesn't matter)
myobject = GetTheObject()
When I use the "is" operator on the object like this
b := myobject is TStrings;
I receive FALSE because the "is" operator is implemented by a TObject.InheritsFrom which goes through virtual tables and each DLL has its own set of vtables that are different.
The situation is even worse with the "as" operator. When I use this I get a "Invalid typecast" exception.
ts := myobject as TStrings;
Is there any solution to this? How to make the operators work across DLLs?