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

前端 未结 3 1167

(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: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 :}

提交回复
热议问题