REALSOFO
REALSOFO

Reputation: 862

Component Build - Required package used for TFDConnection not found

I'm trying to build a new component and I would like to create a property where I would like to associate a TFDConnection object like this:

uses
  System.SysUtils, System.Classes, System.Types, System.UITypes,
  Vcl.Dialogs, Vcl.Graphics,
  ColnEdit, DesignIntf, DesignEditors,
  VirtualTrees, FireDac;

type
  TMyComp = class(TComponent)
  private
    FFDConnection: TFDConnection;
    procedure SetFDConnection(Value: FFDConnection);
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property FDConnection: TFDConnection read FFDConnection write SetFDConnection;
  end;

My problem comes from the fact that FireDac package used inside the component package is not found.

package MyPackage;

...

requires
  rtl,
  vcl,
  VirtualTreesR,
  DesignIde,
  dclFireDAC230; //<--- this package it's not recognized

contains
  MyComp in 'MyComp.pas';

end.

[dcc32 Fatal Error] MyPackage.dpk(36): E2202 Required package 'dclFireDAC230' not found

I take this name from here: enter image description here

How can I identify the name of the required package corresponding to TFDConnection?

Upvotes: 0

Views: 2554

Answers (3)

REALSOFO
REALSOFO

Reputation: 862

Inspired by the answers, I found out that in place of FireDac I should use inside the code of my component FireDAC.Comp.Client like this:

uses
  System.SysUtils, System.Classes, System.Types, System.UITypes,
  Vcl.Dialogs, Vcl.Graphics,
  ColnEdit, DesignIntf, DesignEditors,
  VirtualTrees, FireDAC.Comp.Client;

In fact in a standard app when you drag and drop on a form a TFDConnection, Delphi automatically add to uses all this bellow modules:

uses
  ...
  FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait,
  Data.DB, FireDAC.Comp.Client

Following the link we can see that TFDConnection is defined inside FireDAC.Comp.Client.

Now, by adding FireDAC.Comp.Client to my component, when I try to build my component, Delphi is doing a smart thing by suggesting me what to add to require section from the package.

enter image description here

After clicking Ok, Delphi will automatically change the code to this:

requires
  rtl,
  vcl,
  VirtualTreesR,
  DesignIde,
  dbrtl,
  FireDAC,
  FireDACCommonDriver,
  FireDACCommon;

.dcu files seems to be located to: C:\Program Files (x86)\Embarcadero\Studio\17.0\lib...

Upvotes: 2

Arioch &#39;The
Arioch &#39;The

Reputation: 16045

Indeed. dclFireDAC - is a "design-time" package, it does not have the component, it only advertises it to the IDE. You need to find a "runtime" package with it.

There actually are a lot of ways to find it out with more or less hassle.

I do not have XE3 so I do not know - is there FireDAC sources in it? Can you find *.dpk of FireDAC in a folder of Delphi sources ? c:\Program Files (x86)\Embarcadero\Studio\17.0\Sources.

What unit does declare that component, "FireDac" ? You can check in the help on TFDConnection type or you can CTRL+Click over TFDConnection type in your sources to open the declaring unit. For the rest of the comment I would assume the unit is "FireDAC".

Look into that folder, and there find all FireDAC *.dpk that have "FireDac" as a separate (whole) word in it (any file manager can do that simple text search). If there would be the "FireDAC" unit in contains section of .dpk source - that is the dpk/bpl you need. Here is an example for searching packages with SQLExpr unit (since my Delphi does not have Any-DAC in it).

Example for search for a given word in files with a given mask


Another approach - since BPL is a special case of DLL, you can search through its imports and find where it borrows your component from. You would need a tool like Microsoft Dependency Walker or a similar tool to analyse DLLs (BPLs) relations. Since I do not have AnyDAC in Delphi XE2 I would show the similar search for TDataSet - we would find it in the dclDB160.bpl design-time (advertisement) package, so where can we find the runtime (implementation) package of it?

Example one: ntCore CFF Explorer suite. We open the design-time BPL, search which runtime BPLs it imports and look for our class in the BPLs that seem related. Actually we find both the class and the unit it is declared in. ntCore.com

This tool is powerful, but is lo-level, it shows many separate import records for every BPL. Is there something less power but easier to use?

Example 2: Unreal Commander (or commercial Total Commander) and FileInfo plugin. FileInfo.WLX dependency walker

While there are still many BPL's, they are not repeated. We look for 1st-level BPLs and guess the best match - DBRTL160.BPL Does it have the class we need and search for?

We go to the "Imports" tab and select our candidate "DBRTL160" from the list. Then we scroll the lower pane down and from the bottom we search for our component's Virtual Methods Table FileInfo.WLX virtual methods

Again, we found the component implementation, and the unit it is declared in, and the runtime package that contains that unit.

Any other DLLs cross-dependency viewer would do the same. And since you started developing and using packages you would have to add some of those into you toolbox anyway. When you would optimise the size of files excluding unneeded files, or determine the building order of different but inter-related Delphi projects - you would need one of those viewers anyway.


Another approach: it does not always work, but it might be the most lazy one.

Make a new simplistic single-form EXE project. Go into project properties and turn one "Build with runtime packages" switch.

Compile it and go back to those properties - you would see a list of runtime packages that your EXE needs there. Copy it into Notepad.

Now drop your component in question ( 'TFDConection' ) over the form and compile your EXE again. Go into the project properties and copy the new, updated list of runtime packages.

Paste it into Notepad as the second line and compare those two lines, new and old ones, to see which packages were added after you dropped the component. One of them would be what you need.

Upvotes: 0

da-soft
da-soft

Reputation: 7750

Use FireDAC230, which is run-time package.

Upvotes: 0

Related Questions