If you ever get something similar to
InvalidCastException: [A]Person cannot be cast to [B]Person.
then you are (or more precise: your process is) probably loading the same assembly twice, but from a different context.
.NET allows that, and for reason (side by side loading, appdomains, etc).
Delphi doesn’t (thanks Warren Postma for noticing). But a mistake you see quite often is that Delphi developers try to load the same Delphi type from both an EXE and a DLL wondering why they don’t match. If you want to spread your types in Delphi, then use BPLs (run-time packages) for that. BPLs are similar to .NET assemblies, but cannot be loaded in memory twice.
–jeroen
via c# – InvalidCastException for two Objects of the same type – Stack Overflow.