Packages FAQs (Hydra)
What kind of components MUST be included in Hydra packages?
If you get "Class already registered" at runtime, your code needs packaging. Also, if you get "cannot assign a <class> to a <class>", where <class> is the same classname, that class also needs to go into a package.
Note: for code that requires to be packaged, you can always create one big "MyApplication.bpl" that contains it, to avoid having to deal with changing vendor-provided packages.
What steps are required in Delphi to create a Hydra package containing other packages?
Follow these steps:
- create a new package,
- ensure that only "rtl" and "vcl" are listed in the required section,
- add all the core Hydra units (uHYVisualPlugin and uHYNonVisualPlugn should pull in all you need),
- add any custom units,
- add third party units that need to be packaged (1),
- save your package MyApp.dpk,
- build the package,
- click *CANCEL* when Delphi suggests to add other packages to the requires list,
- change the "Packages" list of your app to "rtl;vcl;MyApp",
- build the application.
(1) As all RemObjects products, most of the Developer Express components and other libraries depend on only one copy being available at runtime.
When and why does Hydra require packages?
Basically, some libraries require that they are only loaded once per process, and will thus require to be packages. (Most) others will work fine when linked statically into both the host and the plugin dll.
If the library code registers a class with Classes.RegisterClass, you cannot have two versions of that code live in the same application domain (i.e. a common RTL package, but separate copies of the library in the exe and dll), because that would mean the same class(name) gets registered twice. In this case, the library needs to be packaged.
There are two common errors when packaging code:
- if you get "cannot assign a <class> to a <class>", where <class> is the same classname.
- "Class already registered" at runtime.