由于循环依赖项错误,无法添加对项目的引用 [英] Cannot add reference to project because of a circular dependency error

查看:202
本文介绍了由于循环依赖项错误,无法添加对项目的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中创建了2个虚拟项目,并将它们分别命名为BALDAL.当我构建它们时,它们会成功构建.如果我将对BAL的引用添加到DAL项目,则添加得很好.但是在将DAL引用添加到BAL项目时,出现以下错误:

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:

无法添加对DAL的引用.将这个项目添加为参考会导致循环依赖.

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?

推荐答案

这是您需要做的:

  1. 在解决方案资源管理器中右键单击DAL项目,然后在上下文菜单中选择项目依赖项.

您现在将看到一个窗口,其中显示了DAL项目的项目依赖项.确保未选中BAL.

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

现在,您应该可以添加参考了...

我希望这有助于我尽量保持简单明了.

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

说明:

您的DAL应该不能访问BAL.您的代码引用依赖项应如下所示:

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

MVC项目-> BAL-> DAL

MVC项目应引用BAL,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.

给出:

  1. 数据 = 原始数字和字符串
  2. 信息 = 将数据处理成有意义的内容
  1. Data = raw numbers and strings
  2. Information = processed data into something meaningful

考虑以下事项: 用户界面应从BAL获取其信息,该信息可以基于DAL构成其数据.

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.

这篇关于由于循环依赖项错误,无法添加对项目的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆