表示层引用数据层

发布于 2024-07-24 22:47:48 字数 102 浏览 4 评论 0原文

我有一个 3 层 .NET 2.0 应用程序。 表示层引用中间层。 中间层引用数据库层。 由于某种原因,当我编译时,数据层的 dll 出现在表示层的 bin 中。 我该如何阻止这个?

I have a 3-tier .NET 2.0 app. The presentation layer references the middle tier. The middle tier references the database layer. For some reason, when I compile, the dll's for the data layer appear in the bin of the presentation layer. How do I stop this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

却一份温柔 2024-07-31 22:47:48

阻止这种情况的唯一方法是将您的一个或多个层设置为服务层(或类似的层)以在物理上分隔您的层。

由于各个层是相互编译的,因此需要存在程序集才能使整个应用程序正常运行。 您认为应用程序在没有所有程序集的情况下如何工作?

The only way to stop this is to make one or more of your tiers a service-layer (or something similar) to physically separate your tiers.

Since your separate tiers were compiled against each other the assemblies need to be there for the entire application to function properly. How do you envision the application working without all the assemblies?

等往事风中吹 2024-07-31 22:47:48

在参考属性中将复制本地设置为 false

set Copy Local to false in Reference properties

走过海棠暮 2024-07-31 22:47:48

复制是可以的,因为存在所谓的依赖关系。 您的中间层取决于中间层上的数据访问和 UI。 您只需跟踪而不引用来自 UI 的数据访问。

It is OK to be copied because there are known as Dependencies. Your Middle tier depends on DataAccess and UI on Middle tier. You have to keep track only not to reference data access from UI.

云雾 2024-07-31 22:47:48

通常我会按如下方式执行物理层应用程序:

  1. UI
  2. Presenter
  3. BusinessLogic
  4. DataAccess
  5. Entity

但我正在改变对此组织的看法。 因为我做过很多项目,其中一些需要维护和改进。 我开始认为这个组织过于单一。 一些作者,如 Ted Faison、Tomas Erl、Robert C. Martin、Andy Aunt 表示,这种层次结构方法有点幼稚。

无论如何......将您的逻辑放入单独的项目中并将它们构建为不同的程序集。 进行层次结构参考,您就会得到您想要的。

Normally I do physical layer application as following:

  1. UI
  2. Presenter
  3. BusinessLogic
  4. DataAccess
  5. Entity

But I'm changing my view on this organization. As I have done lot of projects and some of them demands maintenance and improvements. I start to think that this organization is too monolithic. Some authors like Ted Faison, Tomas Erl, Robert C. Martin, Andy Aunt says that this hierarchal approach is kind of naive.

Anyway... Put your logic in separated projects and build them as distincted assemblies. Make hierarchal references and you'll have what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文