What is the best approach to work around a Circular referencing problem, that is "Dll A references Dll B and Dll B references Dll A, in such a way it becomes quite impossible to compile either...
To give another option for your situation, you should attempt to identify which assembly is the client of the other. Then you need to identify the classes that belong to the client assembly but are being referenced by the non-client assembly. Put these classes into a third "commons" assembly.
It may be the case that there are classes that DEFINITELY belong in the "client" assembly (for instance Form classes belong in the "UI" assembly), but are still being referenced by the "commons" or the "server" assembly. Most likely these classes have functions that the server is calling. You can turn these functions into delegates in the "Commons" assembly, and Events in the "Server" assembly. The "client" assembly would be responsible for registering their delegates on the "Server". And thus you have removed the circular reference between assembly A and B.
You can generally use interfaces to solve this kind of problem. Say you have some class in assembly A that depends on a type Bar in assembly B and that you also want Bar to depend on the Foo type in assembly A. If you introduce an interface IFoo that is implemented by the Foo class, you can now put the IFoo interface in a new assembly, C, and have assembly B depend on assembly C, i.e. change Bar to reference IFoo rather than the concrete implementation Foo. If you need to create instances implementing the IFoo interface in assembly B, you can use a factory pattern.
Circular referencing
moemen.ahmed
Couldn't agree more. See http://www.martinfowler.com/eaaCatalog/separatedInterface.html
tamri
To give another option for your situation, you should attempt to identify which assembly is the client of the other. Then you need to identify the classes that belong to the client assembly but are being referenced by the non-client assembly. Put these classes into a third "commons" assembly.
It may be the case that there are classes that DEFINITELY belong in the "client" assembly (for instance Form classes belong in the "UI" assembly), but are still being referenced by the "commons" or the "server" assembly. Most likely these classes have functions that the server is calling. You can turn these functions into delegates in the "Commons" assembly, and Events in the "Server" assembly. The "client" assembly would be responsible for registering their delegates on the "Server". And thus you have removed the circular reference between assembly A and B.
Anjan Ghose
TheTheTheTheTheThe