Circual Dependencies problems

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

Hi,

I have some circular dependencies that confuses me. I have 2 interfaces that
uses each others interface. When they are compile within the same assembly
there is no problem(?), but when they are in 2 different assemblies i get the
circular dependency problem (When adding reference!)...

Shouldn't it either work in both senarios or not?

And next question, how do i get around this problem.

TIA

----------------------------

interface IA {
IB Foo();
}

interface IB {
IA Foo();
}

- Compiles with success when in they are in same assembly.
- Failes due to "dependecy problems" when they are in their indivdual
assembly.
 
Circular dependencies are (as you have found) only an issue accross
Assembly boundaries, since that is when references are used.

In reality, this is one best avoided; for example, by pushing all the
offending interfaces into a shared base-assembly that several higher-up
assemblies can reference.

The IDE does not support circular references. If you try hard, you can
get the command-line compiler to do it, but I don't recommend it; it is
almost always the wrong design.

Marc
 
Back
Top