Cannot add reference to project because of a circular dependency error

Solution 1:

Here's what you need to do:

  1. Right click on the DAL Project in the solution explorer and select Project dependencies in the context menu.

  2. You will now see a window that shows the project dependencies of the DAL Project. Make sure that BAL isn't checked.

Now you should be able to add your reference...

I hope this helps I've tried to keep it as simple and straight forward as possible.

Explanation:

Your DAL should not be able to access the BAL. Your code reference dependencies should be like this:

MVC project -> BAL -> DAL

The MVC project should reference the BAL, the BAL should reference the DAL. Set up your project like this. Make it work and then you will better understand why this setup is better.

Given:

  1. Data = raw numbers and strings
  2. Information = processed data into something meaningful

Cosider the following: The UI should get its information from the BAL which could be able to compose it's data based on the DAL.

Solution 2:

You can only reference in one way otherwise you get the error like you said. Just do this: delete the reference from your DAL to your BL and make a new one from your BL to your DAL!

Solution 3:

It is implicit in the concept of "layers" that higher layers depend on lower ones, and not the other way round. If 2 "layers" are mutually dependent, then one is not higher than the other, they are not layers in any meaningful sense, and so can be considered to be in the same layer. The same basic principle holds for architectural components or modules, as enforced by Studio for project dependencies. If you use this principle - think of your projects as design modules rather than e.g. just throwing everything into a single project - you will have well-structured codebase which will give you far less problems as it grows in size.