delphipackagecomponentsvclbpl

Delphi, How to install a component with the same name in two different package


I need to install two different component packages, the first one uses BDE connection and the second one uses FireDAC connection, both of them contain a component called "TKsAnalExpr", which is contained in a unit named "UAnalExpr".

I installed one of the package correctly, but when I try to install the second package, Delphi shows this error message:

Registration procedure, Kactus@UAnalExpr.Register in package C:\Entorno Delphi XE3\BPL\Kactus.bpl raised exception class EFilerError: Component TKsAnalExpr can't be registered by package kactus.bpl because it has already been registered by package KactusOP.bpl

I changed the name of the units using a namespace, like in for example PkgeBDE.UAnalExpr and PkgeFireD.UAnalExpr respectively.

But when I try to install the second package again, it shows the same error message above.

I'm using XE3 Upd 1 and FireDAC 8.0.5.

PD: In case someone is wondering, "AnalExpr" stands for "Analizador de Expresiones". Heh.


Solution

  • Simply put, you cannot have two registered components with the same name. There is a single namespace for components within a particular framework (VCL or FMX).

    Consider how the streaming framework resolves something like this in a .dfm file

    object MyComponent1: TMyComponent
    

    It knows that it needs to instantiate an instance of TMyComponent. So it looks up the class with name TMyComponent in that class registry. If it were possible to have two classes with the same name, then that lookup would make no sense.

    You have to ensure that the names of registered components are unique.