Circular reference between two projects

2

I'm working with two projects in a solution .

To use a ProjectA form in ProjectB I referenced the ProjectA in ProjectB , from this I have access to the ProjectA forms.

But what if I want to have access to the ProjectB forms in ProjectA ?

How do I do it? Since you can not reference B in A because a A reference has already been made to B .

    
asked by anonymous 13.04.2016 / 15:41

2 answers

2

As you are thinking, it will cause a circular reference , so you will not be able to do this.

Solution

Without further details about the rules and why you need to split the project into "two parts", it's a little complicated to think of a practical solution that fits your project needs. At first and with the little information you put in the question, I can think of two ways to solve this.

1. Leave everything in one project

After all, if you need to use the ProjectA forms in ProjectB and vice versa, why would you worry about leaving them in separate projects? Perhaps there is some rule for this, but as has not been said in the question, we can assume that keeping everything in one project is a better idea than the current one.

2. Create a base project and reference the two projects

In this case, you would create a third project and add references from the other two. There is not much mystery, but it may be unnecessary work and using the first approach is a much better idea.

    
13.04.2016 / 15:52
1

A possible solution if this is necessary for your solution is to modify the structure of your projects.

Creating a third project ProjetoBase , where you will pass all Forms that are common between ProjetoB and ProjetoA , and make ProjetoB and ProjetoA refer to ProjetoBase . So the 2 projects have access to common Forms between them.

We can illustrate this relationship as follows:

  • ProjetoBase (For Forms and common resources between projects)

    • FormBase1
    • FormBase2
    • FormBase3
    • FormBase4
  • ProjetoA

    • References
      • ProjetoBase (which gives access to ProjectBase form)
    • FormA
    • ... Other specific forms ...
  • ProjetoB

    • References
      • ProjetoBase (which gives access to ProjectBase form)
    • FormB
    • ... Other specific forms ...
13.04.2016 / 15:51