Reputation: 16865
I have a solution with two projects inside. Say Project A
and Project B
. In the first project I have:
namespace MySolution.ProjectA {
public class ClassA { /* Referencing something in MySolution.ProjectB ns */ }
}
In the other project I have:
namespace MySolution.ProjectB {
public class ClassB { /* Referencing something in MySolution.ProjectA ns */ }
}
ClassA
uses ClassB
. So Project A
references Project B
.
In ClassB
I need to use ClassA
, so I need to reference Project A
from Project B
but can't because a circular reference would occur. How to handle this?
I know that this condition means that something in the application design was not correct, but I need to do this to inspect a legacy application.
Upvotes: 1
Views: 58
Reputation: 517
I encountered a similar scenario in the past. There were two strategies that were used:
All roads lead to ugliness, but this can work for debugging.
Upvotes: 1
Reputation: 16199
A circular reference can never be, so what you do, is take out the thing you need to reference from Project B in Project A and put it into Project C.
Project A & B can then reference C but C doesn't reference A or B.
Upvotes: 3