Jump to content
magicman

Application Loading incorrect bpl

Recommended Posts

Hi everyone,

 

I have a deplhi project with bpls stored in its own application folder that will get loaded up when my application starts. However, i noticed that if i build a bpl and drop it in my desktop, my application will use the bpl located in my desktop instead of the one in my applications folder (where my other bpls live). I tried looking for a solution but cant seem to find anyone who had a similar issue. Any suggestions?

Share this post


Link to post

Are you linking statically to the BPL at compile-time, or are you loading the BPL dynamically at runtime?

Edited by Remy Lebeau

Share this post


Link to post
19 hours ago, Remy Lebeau said:

Are you linking statically to the BPL at compile-time, or are you loading the BPL dynamically at runtime?

Well this is my company software, and the delphi application is installed on our virtual machines. When the application is installed, the bpls get installed to a folder (ex: C:/Program Files (x86)/Application/{Bpls}). I build one of the bpls on my own machine with embarcadero delphi 12. and dropped it on my VMs Desktop. When i launch the application it uses the bpl on my desktop (which should not happen, but it is). And to answer your question, i think the application is linking statically to the Bpl, because if i delete the bpl from my desktop and the application folder, it causes an error. 

Edited by magicman

Share this post


Link to post
38 minutes ago, magicman said:

the bpls get installed to a folder (ex: C:/Program Files (x86)/Application/{Bpls}).

Is this folder is added to the PATH variable or how do you make Windows find those libraries?

 

Also, which folder is given as the starting folder when you launch the application?

Share this post


Link to post
26 minutes ago, magicman said:

And to answer your question, i think the application is linking statically to the Bpl, because if i delete the bpl from my desktop and the application folder, it causes an error. 

Actually, that doesn't answer my question at all, so let me rephrase it...

 

When the application begins, is the BPL being loaded automatically by Windows (are you seeing a standard system error message?), or is the BPL being loaded by the application's code using Delphi's LoadPackage() function and then displaying its own error message? Can you provide a screenshot of the error message? 

 

Did you check Windows' PATH environment to see if the Desktop folder is present in it and is before the BPL folder?

 

The best way to ensure that the BPLs are being loaded only from the app's BPL subfolder is to load them manually in code using LoadPackage() specifying the absolute path to each BPL. If that is not an option, then the next best option is to make sure the BPLs are marked for delay-loading in the app's config and then call SetDllDirectory() or AddDllDirectory() at app startup to add the BPL subfolder to the DLL search path before the standard system search path. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×