Is it really true that a pointer to a structure in the exe is not valid in the dll when pointing to exactly the same structure?
The pointer is valid. But the question is how exactly the same the structure is.
In my understanding a "object" in eiter delphi and fp is a pointer so a record of method pointers and elements. Where is the difference between the pointer to e.g. a DB object if I pass it to the dll and assign it to a DB Object?
Ehm... there are objects and there are objects.
Sometimes and instance of a class is called object (type = class) and you have record like objects (type = object). Both are indeed some record with members and method pointers. And, for an exe and dll, if they are comiled with the same version, their layout is the same.
However, with a class you can do more. For instance you can ask a class if it descends form a certain class like:
if MyForm is TForm then DoSomething
How does this work ?
One of the members (the first iirc) of the instance of a class "record" is a pointer to the class definition. This pointer is compared to see if something is the same class.
For your exe and dll, this pointer points to their own a piece of readonly memory, part of your exe or dll. So when comparing a class instance created in your exe with one created in your dll, the "is" operator will fail.
This is just one of the problems. However, when you only call some methods of it, they usually will work, unless they modify some internal dynamic type (like a string) and you don't have a shared memorymanager