Delphi – How to diagnose “Cannot access package information” error in Delphi IDE

custom-componentdelphiidepackages

I am developing a set of TFrame-based components that inherit from one another (as so many who have helped me tremendously along the way already know!), and am running into yet another little "snag," related to packages and installation.

I have essentially the following hierarchy:

TFrame
  TBaseFRame
TBaseSizeableFrame
  TViewerType1
  TViewerType2

…and a panel, TExtRzPanel, which inherits from a Raize Panel and adds some sizing / moving functionality to it, along w/a few other properties / features. TBaseSizeableFrame uses this component, and passes through much of it's functionality to the frame itself, so I can develop the compound Viewer components visually. Overall it works well.

The TFrame descendants are all registered to the palette (see
this post for related question I asked earlier). Currently, I have packages set up like this:

  • MyPanels – Contains the TExtRzPanel
  • BaseFrames – Contains TBaseFrame, and TBaseSizeableFrame
  • ViewerSet1 – Contains one Viewer frame-based component, and a non-visual component which calls that Viewer as a dialog form. (I'm planning on this package having a few other viewers in it as well).

The main error that started my current chaos was this one:

Cannot access package information for package 'MyPanels.bpl'

I'm dizzy enough with this thing now that I'm having trouble remembnering the exact sequences of what I've tried and in what order, but the trouble seems to have started when I added the dialog form to ViewerSet1, which uses a TViewer frame from the same project, and which (of course) thus uses a TExtRzPanel (which is the package the IDE is complaining about).

Based on this I've deleted the DCP files (and DCU files too, I think at some point), uninstalled the packages, and then recompiled/reinstalled them MyPanels -> BaseFrames, and got them all working to that point, but upon installing ViewerSet1 the whole thing blows apart again.
Other errors I noted along the way of trying to figure this out include these:

  • Package C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Bpl\MyPanels.bpl can't be installed because it was created with a different version of Delphi or CBuilder.
    Do you want to attempt to load this package the next time a project is loaded?
    (Note: I've only built this with ONE version of Delphi — Delphi 2007)
  • At one point, I noticed that the package description for MyPanels didn't "take" (i.e. it showed up as just the file name is Tools -> Compoenent -> Install Packages), which makes me think maybe there are two versions of the file the IDE is finding / using, but I'm not seeing/finding that to be the case.
  • The warning Delphi gives when starting up, indicating it can't load an installed package, and do you want to load it next time, etc.
  • Cannot access package information for package 'MyPanels.bpl' (Lather, rinse, repeat)

Any and all help / direction re: how to diagnose, along with any conceptual explanation which could help me understand what to even look for, would be most appreciated. THANKS IN ADVANCE. You folks have been SO helpful here! Thank you. : )


Update later:

After setting this aside for a bit and coming back to it, I tried deleting all the DCP / DCU MyPanels files, and then installing the three packages step by step. (VMWare was worth its weight in gold here — snapshots after each success, so as to not have to start over at the bottom if/when things went wrong). Turns out, if I removed the dialog form from the ViewerSet1 pakckage, it installs OK. If I then add the form again (which doesn't show up with its DFM, like I ran into
here
), it seems to install OK. I've got all the components installed not and seemingly working OK (and snapshot the whole thing in my VM!), but I'm still not sure what went wrong nor why. What could adding that form have done initially which would cause these kinds of errors? Any idea?

Even a better explanation / understanding of what kinds of things can cause the "Cannot access package information" error would be helpful in the long run, I think.

Best Answer

OK, there is definitely something that I'm missing. From SysUtils:

function PackageInfoTable(Module: HMODULE): PPackageInfoHeader;
var
  ResInfo: HRSRC;
  Data: THandle;
begin
  Result := nil;
  ResInfo := FindResource(Module, 'PACKAGEINFO', RT_RCDATA);
  if ResInfo <> 0 then
  begin
    Data := LoadResource(Module, ResInfo);
    if Data <> 0 then
    try
      Result := LockResource(Data);
      UnlockResource(Data);
    finally
      FreeResource(Data);
    end;
  end;
end;

So, if you are getting this last error, your package does not have the necessary PACKAGEINFO resource attached to it. This is probably also the cause of your first error (created with a different version of Delphi).

Appologies for asking this, but did you create the package by selecting File->New->Package-Delphi? I'm asking, because this have all the hallmarks of a library that simply has the bpl extention.

If you are certain that the package was created in the right way, may I suggest that you search your entire hard drive for a DLL file of the same name. And all the bpl packages that you do find, you should execute the following for:

C:\Program Files\CodeGear\RAD Studio\5.0\bin\tdump.exe mypackage.bpl>mypackage.txt

In your mypackage.txt file there should then be a resource called PACKAGEINFO.

Alternatively, you can download filemon.exe from live.sysinternals.com, set a bds filter and spy on what the IDE is actually trying to load. It could very well be another package that is being loaded by your package and that this second package does not have PACKAGEINFO attached.