Circular Reference Problem

Hi,

I've got a problem that I have two assemblies:
Assembly A and Assembly B

A class (inherited from a form) in Assembly B references Assembly A many times to get common resources and controls, and Assembly A then declares a variable of that class in Assembly B and shows the dialog. Unfortunately, since they therefore both need each other, I have a circular reference and I can't compile either assembly. What do I do?

What is the best solution? I can't move them to the same project (not possible), or move the methods to the other class (since the entire class is called).
[628 byte] By [AberAber] at [2007-11-20 10:58:58]
# 1 Re: Circular Reference Problem
If you have a circular reference between two assemblies it is a common way to resolve it by using a third assembly.

In your case create an assembly with the controls and ressources. So you can use assembly A to initialize the controls and you can use assembly B to show the controls.
torrud at 2007-11-9 11:36:05 >
# 2 Re: Circular Reference Problem
Thank you for the reply.

Assembly A: Contains Controls relying on contained Resources, one of the Controls instantiates a dialog from Assembly B
Assembly B: That dialog that was instantiated uses Controls from A

I can't figure out how to make a third assembly, since this third assembly would require Assembly B to be compiled, which required Assembly A to be compiled, which required new Assembly C to be compiled, which required Assembly B to be compiled, repeat.

Am I thinking about it wrong? Thanks!
AberAber at 2007-11-9 11:37:06 >
# 3 Re: Circular Reference Problem
You have to split the logic from the presentation. Put in assembly A the logic and in assembly B the presentation and in assembly C the controls, components etc.

So if you want to show a dialog from assembly C in assembly B you have to instantiate/initialize the dialog in A and then you give the dialog to B. So you have straight references lines.

B -> A -> C and B -> C

You have this trouble because your application design is not clear. Try to read some articles about n-tier application design. So you will never get this trouble again.
torrud at 2007-11-9 11:38:16 >
# 4 Re: Circular Reference Problem
Can you move the dialog (form?) to assembly A? You can still leave the logic in B. . .
trenches at 2007-11-9 11:39:11 >