Cannot add reference to project because of a circu

2020-02-09 06:36发布

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 BAL to the DAL project, it added nicely. But while adding the DAL reference to the BAL project, I get the following error:

A reference to DAL could not be added. Adding this project as a reference would cause a circular dependency.

Can anyone help me to solve this error?

8条回答
家丑人穷心不美
2楼-- · 2020-02-09 07:00

In my case I copied a project file without generating a new ProjectGuid. Since Visual Studio uniquely identifies projects using the ProjectGuid, it assumed the project was trying to reference itself.

查看更多
够拽才男人
3楼-- · 2020-02-09 07:04

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.

查看更多
登录 后发表回答