Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't load package %s error while installing a package

I'm testing on Delphi 2007 and my groupproject is composed by 2 packages.

enter image description here

PackageRun.bpl

It's marked as "runtime only" and contains a unit named "uMyTestRun.pas" in which is defined an empty TFrame descendant:

unit uMyTestRun;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs;

type
  TMyTest = class(TFrame)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

end.

PackageDes.bpl

It requires PackageRun.bpl, it's marked as "designtime only" and contains a unit named "uMyTestDes.pas" in which I wrote the following code:

unit uMyTestDes;

interface

uses
  Classes,
  uMyTestRun;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('MyComponents', [TMyTest]);
end;

end.

Output directories of both packages are in Library paths (Inside there are bpl, dcp and dcu).


Trying to install PackageDes.bpl (Component, Install Packages..., Add...), I'm getting the following error:

Can't load package C:\<...>\PackageDes.bpl. Impossibile trovare il modulo specificato.

The last part of the message is in my OS's language, in english it should be something like "Can't find specified module". (My OS is Windows 10 Pro 64bit).

PackageDes.bpl is exactly in the same path shown in the error message (C:\<...>\PackageDes.bpl). After some tests, I found that the error disappear by removing the following line from uMyTestDes.pas unit:

RegisterComponents('MyComponents', [TMyTest]);

Is there something wrong in my code/projects/environment?

like image 242
Fabrizio Avatar asked Dec 19 '22 13:12

Fabrizio


1 Answers

Run Process Monitor from http://SysInternals.com and set the filters to intercept only file operations ( toolbar rightmost buttons ) of your Delphi IDE process (check the process name in TaskManager or shortcut properties (it is bds.exe for Delphi XE2), then add the filter similar to Include / Process Name / Ends With / bds.exe ).

Then clear the log in PM, switch to Delphi and try to load the package, then as soon as error pops up switch back to PM and stop capturing events. Try to do it fast as you can, for example do not waste your time closing error box.

Now you would get a trace of file I/O activity of Delphi loading the package of yours (and some other background activity noise - the faster you do the less noise there'd be). In that trace look for all the errors and see where and which package Delphi tries to find.

You can also try Microsoft Dependency Walker or similar tools to se if your Design-Time BPL has all the DLL-dependency tree resolvable. Personally I usually use Unreal/Total commander with FileInfo plugin or ntCore CFF Explorer.

like image 136
Arioch 'The Avatar answered Dec 24 '22 00:12

Arioch 'The