“Cannot load package A, it contains unit X, which is also contained in package B”

前端 未结 3 1159

(More package/component install fun for me -- thanks everyone for all your help to date).

I am getting the error listed as the title, in Delphi 2007. Package A is

相关标签:
3条回答
  • 2020-12-16 16:37

    Just because you deleted the component doesn't mean you deleted the module name from the USES clause--those aren't auto-deleted.

    0 讨论(0)
  • 2020-12-16 16:47

    It could also be related to this question.

    Unit X is clearly being linked into both packages. There's a couple of ways around this:

    • create a new package (we'll call it Package C) with Unit X (and any other dependencies), then change Package A and Package B to both use Package C; or...
    • include Unit X in Package B, and have Package A use Package B (which is a more compact form of the first solution).

    If the viewers are explicitly mentioned in your Package B code, then Package B most certainly should be using Package A (ie, there should be an explicit dependency there). If that indication of shared code isn't explicitly made, B will compile it's own version of the code into B, leading to the problem you're seeing.

    Now, if that dependency is OK, adding a reference to Package A from Package B should clear this problem up right away; after all, B will be "using" the code in Package A, and the same units won't be getting compiled into two packages. However, if this introduces circular references (I can't remember whether A uses B or not), then you might have a bit of refactoring to to :}

    0 讨论(0)
  • 2020-12-16 16:47

    Loren:Requires clause, since it is a .dpk, you can't USES a packages afaik.

    I'd simply clean up the $(BDSDIR)/projects/ dir, my own projects dir to remove B.dcp and all dcu's for the units that were in B and then rebuild A.

    Another thing to check if there is a component registered that depends on B.

    0 讨论(0)
提交回复
热议问题