2
votes

I have a VCL Forms app that includes a reference to a BPL file that I created. I added the unit name of a frame component from the BPL to the uses clause of the main window of the VCL app. The app builds fine, but when I run it, it dies before reaching the first line " Application.Initialize" in the project file. If I comment out the frame's unit from the uses clause, the app starts up and runs fine.

What could be causing the fatal error as the app starts up?

I'm guessing there is a problem with loading the BPL file on startup, but I'm having trouble finding the issue. Thank you.

More info below... The VCL app is in XE5 and I am trying to convert it into a BPL. The entire app resides in a single TFrame control which houses many other buttons and frames that give access to all of the underlying functionality of the app. This "main frame" is then placed in the main form of the app which is empty except for a few menu items. The original app builds and runs fine.

I created a new BPL project, and added this "main frame" component in an effort to create a BPL package that was essentially my entire app, and that could be used for a normal stand-alone exe app like before, or be added to a RemObjects Hydra plugin module, and ultimately be embedded into a C# app. The BPL project with the single "main frame" component builds okay with no errors.

I then created a new VCL Forms app with a single empty main form, and set the Project's "Options->Packages->Run-time Packages" to include my new BPL, and checked-off the "Link with run-time packages" option. I added the "main frame's" unit to the uses clause of the main form, and everything builds without errors.

The problem: When I run the app from XE5, it appears to begin to start-up as normal, but it dies before ever reaching the very first line of code "Application.Initialize;" in the project file. Note that I haven't written any code yet to create an instance of the "main frame" housed in the BPL. I've only added its unit to the uses clause. No error messages are shown, and nothing is posted to the Build or Output windows in XE5. If I comment out the "main frame's" unit from the uses clause, then the app runs fine, and the empty main window is shown.

Note: The app uses JVcl, NativeXml, TsiLang, ZipForge, & FastReports.

1
Yup. Sounds like the bpl cannot be found. Why do you think it should be found?David Heffernan
BPL files need to be accessible from the system path or in the application folder. You should make sure that the BPL file is in one of those two locations.Graymatter
@Graymatter Technically they are searched using the DLL search order: msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspxDavid Heffernan

1 Answers

0
votes

The symptoms you describe are those of a failed resolution of a load time dependency. From what you have described that could very well be due to your BPL file not being located at load time. Load time package dependencies are handled by the system loader and so the DLL search order applies. Typically you would make sure that dependent modules are in the same directory as the executable file.

Load time dependency failures are not well handled when running under the debugger. You'll get a better error message if you start the executable directly. If that's not enough to identify the problem use Dependency Walker in profile mode to obtain detailed diagnostics of any load time errors.

One final comment regarding Embarcadero's advice for package deployment. The official Embarcadero documentation still recommends installing shared packages to the system directory. Whilst this was common practice 20 years ago under Windows 3.1, nobody should be doing this in the 21st century. Please don't follow this particular advice from Embarcadero and please do respect the fact that the system directory belongs to the system.