Circular reference between two projects

Asked

Viewed 2,275 times

2

I’m working with two projects in one Solution.

To use a form of Projectoa in the Projectob I made reference to the Projectoa in the Projectob, from this I have access to the Projectoa.

But what if I want to have access to the Projectob in the Projectoa?

How do I do it? Since it does not allow referencing the B in the A since a reference to the To in the B.

  • If you meant "Projectob in Projectoa" instead of "Projectob in Projectob", this is not possible because it would cause circular reference.

  • Yes, even if it does, it has no way to access the B-projectA?

  • The way you’re doing it is impossible.

  • A possible solution if this is necessary for your solution is to create a third base project, where you will have all the Forms that are common between Projetob and Projetoa and make the Projetob and Projetoa reference the Projetobase. so the 2 projects have access to the common forms among them.

2 answers

2


The way you’re thinking, it’ll cause a circular reference, soon, you won’t be able to do it.

Solution

Without more details about the rules and why you need to divide the project into "two parts" it’s a little tricky to think of a practical solution that fits the needs of your project. At first, and with the little information you put into 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 Projectoa in the Projectob And vice versa, why would you bother leaving them on separate projects? There may be some rule for this, but as not stated 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. It doesn’t have much mystery, but it may be that this is unnecessary work and using the first approach is a much better idea.

  • Thank you, that’s definitely the best way!

1

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

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

We can illustrate this relationship as follows:

  • ProjetoBase (For Forms and common resources between projects)

    • FormBase1
    • FormBase2
    • FormBase3
    • FormBase4
  • ProjetoA

    • References
      • ProjetoBase (what gives access to the forms of the Projectobase)
    • FormA
    • ... Other Specific Information Systems ...
  • ProjetoB

    • References
      • ProjetoBase (what gives access to the forms of the Projectobase)
    • FormB
    • ... Other Specific Information Systems ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.