2

I have the following problem:

I have interfaces IA in the ProjectA.dll and IB in the ProjectB.dll (IB inherits IA). When I try to implement IB in any another project the both references are required. Well, the requirement of a reference on the ProjectB.dll is expected, but I was little bit confused, that a reference on the ProjectA.dll is needed too.

Does anybody know how is this feature called and where can I find detailed information about this behavior?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Warlock
  • 7,321
  • 10
  • 55
  • 75
  • 1
    @Jon Are you suggesting that if `A` was a base **class** in one assembly, and `B` was a deriving class in another assembly, then in order to derive from `B` in a third assembly, that third project would only have to reference `ProjectB.dll`, and not `ProjectA.dll`? Because "classes do really "inherit" from each other". – Jeppe Stig Nielsen Nov 20 '12 at 12:06
  • @JeppeStigNielsen: On second thought that wasn't the best theory I 've ever come up with. :/ – Jon Nov 20 '12 at 12:16
  • Thank you guys, I checked both theories with interfaces and classes and in the both cases ProjectA reference is required. From one side it is clear, because we need references on all classes, that are used. From another side the ProjectB already has metadata with a reference on the ProjectA. – Warlock Nov 20 '12 at 12:29

1 Answers1

3

You'll need a reference to all of the assemblies that contain the classes involved in any interface you might implement. Otherwise, how will the runtime know what the definition of any such class is?

tomfanning
  • 9,552
  • 4
  • 50
  • 78
  • 1
    But the ProjectB already has a reference on the ProjectA, so the runtime should know what is IA. Therefore I was confused %) – Warlock Nov 20 '12 at 11:36
  • 1
    Cheers for accepting. Well, as you've found out, this is not the way the CLR is designed or implemented. See this question for a full explanation of the behaviour: http://stackoverflow.com/questions/10210729/why-do-i-sometimes-have-to-reference-assemblies-referenced-by-the-assembly-i-r. – tomfanning Nov 20 '12 at 13:22