What forms the forms and datamodules in a Delphi application is the code contained in the main program's body ( .dpr file ). Delphi automatically puts this code every time a new form or datamodule is added to the project when it comes to a .EXE .
When it comes to a package project however, such a code is not automatically included.
You will need to manually instantiate all the objects you want inside a package . This is especially true when the programmer decides to load the runtime package manually, as it seems that is what you are doing (calling LoadPackage
).
One way to pre-initialize a series of objects within the package is to choose a unit and add the code for the creation of the instances in initialization
of this unit .
When a package is loaded, the existing code within the initialization
session of all the units runs in some uncontrolled order. When the package is unloaded, the existing code within the finalization
sessions of all the units runs, again without a guarantee of order.
I recommend reading an interesting article that might be of value to you. This article makes a comparison between the use of DLLs and packages and shows how the latter are easier and more straightforward, since all types declared inside it are available for use as soon as the package in> to be loaded.