Circual Dependencies problems

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.
 
M

Marc Gravell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top