Cannot add reference to project because of a circular dependency error

前端 未结 9 1086
不思量自难忘°
不思量自难忘° 2020-12-15 15:07

I created 2 dummy projects in my application and named them BAL and DAL. When I build them, they build successfully. If I add a reference to

9条回答
  •  半阙折子戏
    2020-12-15 16:04

    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.

提交回复
热议问题