XDataClient and a service interface inside a plugin runtime only BPL

I am creating a windows firemonkey client application with a plugin system, when login form is in the exe and there are some modules with specific operations in them.
Inside of each BPL module, separated by the MVVM design pattern, I have a main window with some commands, these commands accesses the service tier when resides the XDataCient object and it includes the servicecontract with the server as well.
When I call my

function getCustomerList: TList<TCustomerDTO>;

function, the instruction

WebService := Client.Service<ICustomerWebService>;

the exception: "Exception class EXDataInterfaceServiceNotFound with message 'Interface "ICustomerWebService" not registered as a service contract" is raised.

When I test the same instrucción inside the exe everything works perfect.
Is there any problem with the BPL or I need to consider something else or maybe is impossible the paradigm I am trying to create?

Thanks in advance.

Are the packages loaded dynamically using LoadPackage?

It depends on how your plugin system is implemented.

The unit where is ICustomerWebService is added to the package, to the exe...? To a common package?

This is more a Delphi issue - related to the way BPLs are loaded, units are initialized, RTTI information is shared among packages, etc..

Thanks for the answer! :slight_smile:
I tryed to include ICustomerWebService unit in the CustomerModule.BPL package, loaded dinamically using LoadPackage. It didn't work.
Then I put the unit in the exe project... same result.
I will try to include in a common package and see what happen.
My plugin system can load every packade located in the directory and containing an extension *_snap.bpl. But after that, I specifically ennumerate wich modules are included in the current program. I have to create 3 applications for Windows, as a first stage, and then create the Android version of them. The modules, packages, are for generic use. Some applications uses Customer support, another can use vehicles management support, other one can use employees, and so on. So, the modules are reusable.
That why I decide not to use a monolitic application including everything.
So, a created modules. Some of them are system modules (config, connection, models, controllers, utils) marked as required packages, and others are dinamically loaded.
I created the servers already using Postman to validate the endpoints and now I am creating the REST Client applications.
That's why my question.
Is there any example code, a tutorial or blog for a case like mine?

What do you mean by this?

Do you call InitializePackage to properly initialize them?

I think using a common unit is something to try, indeed.

It worked!
I used a common package, WebServices.bpl, when the Service Contract interface resides and I shared with my exe and my plugin package.
Indeed, my plugin system uses the same aproach and every plugin package is registered in the PluginManager in the exe.
Every plugin package in capable to be registered in te application but I decided to define wich plugin packages is part of the specific application. Instead of load *.snap.bpl files in the directory, I pass a list of specific files for every application.
Thanks so much for the hint! XData is realy fast and good.
I will continue now with my project.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.