I was going to use the idea of dynamically loading the BPL and passing instances of objects from the main application to the method in the BPL. This creates problematic units between the application being used and the BPL.
I wrote a small little prototype that did this, and I was curious how Delphi internally manages the differences between the classes defined in the application and the BPL.
For example, let's say the base class of widgets, for example:
TmyWidget = class private fId:Integer; fDescription:String; public procedure DoSomething1(); end;
Now the application and the BPL are built using a device containing the TmyWidget class. Later, something changes in TMyWidget and the application is rebuilt, but the BPL is not (or vice versa). I added another DoSomething2 () method and created an instance of TmyWidget in the application and passed it to the BPL for processing and basically, it worked. But this is obviously fraught with potential problems.
If another dynamically loaded BPL also uses TmyWidget, then things get even more interesting. It seems to work, but it is definitely not perfect.
The main question is: how do you usually transfer objects to the main application and DLLs or BPLs? I have never done this before, and probably for a good reason, but I have this idea that lends itself to this approach ...
I would suggest that the best approach is to serialize the object and transfer these bytes and deserialize it to a DLL / BPL so that this process takes into account potential version differences between the host and the dynamically loaded module, but I was hoping the new SimpleSharedMem parameter could bring this new functionality without overhead serialization, but it doesn't seem to be very useful if you don’t strictly adhere to the fact that the application and dll are rebuilt with any general code changes ... but in this prototype the application remains fairly constant, and dynamically loaded modules will change frequently when functions are added to TmyWidget. (The server application serves as a factory to build TmyWidget based on client requests, and the application will pass instances to various modules for processing.)
source share