Packages Frequently Asked Questions

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 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:
    • CrossPlatform: Hydra.Core.NonVisualPlugin.pas
    • VCL: Hydra.VCL.NonVisualPlugin.pas & Hydra.VCL.VisualPlugin.pas
    • FMX: Hydra.FMX.NonVisualPlugin.pas & Hydra.FMX.VisualPlugin.pas
  • add any custom units,
  • add third party units that need to be packaged,
    As all Remoting products, most of the Developer Express components and other libraries depend on only one copy being available at runtime.
  • 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.

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 is the same classname.
  • Class already registered at runtime.