简体   繁体   English

安装包时无法加载包 %s 错误

[英]Can't load package %s error while installing a package

I'm testing on Delphi 2007 and my groupproject is composed by 2 packages.我正在 Delphi 2007 上进行测试,我的 groupproject 由 2 个包组成。

在此处输入图片说明

PackageRun.bpl包运行文件

It's marked as "runtime only" and contains a unit named "uMyTestRun.pas" in which is defined an empty TFrame descendant:它被标记为“仅运行时”并包含一个名为“uMyTestRun.pas”的单元,其中定义了一个空的 TFrame 后代:

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:它需要 PackageRun.bpl,它被标记为“仅限设计时”并包含一个名为“uMyTestDes.pas”的单元,我在其中编写了以下代码:

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).两个包的输出目录都在库路径中(里面有 bpl、dcp 和 dcu)。


Trying to install PackageDes.bpl (Component, Install Packages..., Add...), I'm getting the following error:尝试安装 PackageDes.bpl(组件、安装包...、添加...)时,出现以下错误:

Can't load package C:\\<...>\\PackageDes.bpl.无法加载包 C:\\<...>\\PackageDes.bpl。 Impossibile trovare il modulo specificato.不可能的 trovare il modulospecificato。

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). (我的操作系统是 Windows 10 Pro 64 位)。

PackageDes.bpl is exactly in the same path shown in the error message (C:\\<...>\\PackageDes.bpl). PackageDes.bpl 与错误消息 (C:\\<...>\\PackageDes.bpl) 中显示的路径完全相同。 After some tests, I found that the error disappear by removing the following line from uMyTestDes.pas unit:经过一些测试,我发现通过从 uMyTestDes.pas 单元中删除以下行,错误消失了:

RegisterComponents('MyComponents', [TMyTest]);

Is there something wrong in my code/projects/environment?我的代码/项目/环境有问题吗?

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 ).http://SysInternals.com运行 Process Monitor 并将过滤器设置为仅拦截 Delphi IDE 进程的文件操作(工具栏最右侧的按钮)(检查 TaskManager 中的进程名称或快捷方式属性(Delphi XE2 为 bds.exe) ,然后添加类似于 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.然后在 PM 中清除登录,切换到 Delphi 并尝试加载包,然后一旦出现错误就切换回 PM 并停止捕获事件。 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).现在,您将获得 Delphi 加载您的软件包的文件 I/O 活动的踪迹(以及其他一些背景活动噪音 - 执行得越快,噪音越小)。 In that trace look for all the errors and see where and which package Delphi tries to find.在该跟踪中查找所有错误并查看 Delphi 尝试查找的位置和包。

You can also try Microsoft Dependency Walker or similar tools to se if your Design-Time BPL has all the DLL-dependency tree resolvable.您还可以尝试使用 Microsoft Dependency Walker 或类似工具来确定您的设计时 BPL 是否具有可解析的所有 DLL 依赖关系树。 Personally I usually use Unreal/Total commander with FileInfo plugin or ntCore CFF Explorer.我个人通常使用带有 FileInfo 插件或 ntCore CFF Explorer 的 Unreal/Total 命令。

Easy way to solve this issue is to add a post build action to your run time project:解决此问题的简单方法是向运行时项目添加构建后操作:

copy "$(OUTPUTDIR)\$(OUTPUTFILENAME)" "$(BDSCOMMONDIR)\Bpl"

The command above copies your run time file to the default IDE Bpl location.上面的命令将您的运行时文件复制到默认的 IDE Bpl 位置。

I had a similar issue.我有一个类似的问题。 In my case I had the same library name in a different Delphi version BPL path.在我的情况下,我在不同的 Delphi 版本 BPL 路径中有相同的库名称。 I found out the solution for my issue looking at the comments above, so this is only a reminder for basic things to check:我在上面的评论中找到了我的问题的解决方案,所以这只是提醒检查基本事项:

  • BPL path have to be included in your OS path variable; BPL 路径必须包含在您的操作系统路径变量中;
  • Search for a BPL module with the same name in other OS path before the right one (mutiple Delphi version installations).在其他操作系统路径中,在正确的(多个 Delphi 版本安装)之前搜索具有相同名称的 BPL 模块。

Try to change the register procedure to uMyTestRun unit.尝试将register过程更改为uMyTestRun单元。

unit UMyTestRun;

interface

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

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

procedure Register;

implementation

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

Now, the package will install correctly.现在,该软件包将正确安装。

Regards.问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM