循环依赖性错误 [英] circular dependencies error

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

问题描述

现在这是一个困扰我过去一周的难题,因为我只想提高我的生锈编程技巧,我遇到了这个视频http://www.youtube.com/watch?v=oFgl71x1PX4它似乎很有趣,我试图把它作为灵感,并试图跟随脚步。

但我可以告诉你我已经试过站在我的头上,无法解决这个问题,我不知道我知道正在编写这个程序的程序员已经给观众带来了仙尘,他让它变得如此简单和实用,但是我无法通过添加参考位,这是一个三轮胎程序,我猜,它是Access和Domain and Session。相信我,我已经尽了最大努力主要的Access将在任何情况下都不会让我添加参考并继续给我循环依赖性错误。

他是否隐藏了什么或在46岁时作为新手我不能得到它,有什么问题?我正在使用Visual Studio 2013!

Now here is a conundrum which is bugging me for the past week, as I just want to brush up my rusting programming skills I come across this video "http://www.youtube.com/watch?v=oFgl71x1PX4" it seem quite interesting and I tried to take that as an inspiration and tried to follow the footsteps.
But I can tell you I have tried standing on my head and could not solve this problem, I don’t know that programmer who is writing this program has thrown fairy dust on spectators, he makes it so easy and functional but hell I cannot get pass the adding references bit it’s a three tire program I guess, it’s Access and Domain and Session. Believe me I have tried my best The main Access will in no circumstance will let me add reference and keep on giving me circular dependencies error.
Is he hiding something or as novice at the age of 46 I cannot get it, what is the problem ? I am using Visual Studio 2013 !

推荐答案

您不仅可以毫不犹豫地添加引用 - 他们说这需要访问此程序集中的类和如果您只是随意添加它们,您将获得循环引用。这是因为它会查看您引用的程序集以确定它们是否已更改,因此需要再次加载它们。如果程序集A引用程序集B和B的更改,则需要重建A,因为它可能正在使用已更改的B中的代码。要检查B的更改,它也会查看它的引用 - 所以它B引用A,然后你有一个循环,既不能成功编译,因为编译A意味着B需要重新编译,这意味着A需要是重新编译。 VS不喜欢那个! :笑:



如果你有三个程序集:PresentationLayer,BusinessLayer和DataAccessLayer,那么显然PL需要访问BL,可能还有DAL - BL应该永远不要尝试访问PL,DAL也不应该。



如果有两个程序集需要访问另一个程序集的情况,那么最好的办法是将公共代码分成一个或多个不需要外部引用的离散程序集,并让两个原始程序集引用它。
You don't just add references willy-nilly - they are saying that "this needs to access classes in this assembly" and if you just add them at will you will get circular references. This is because it looks at the assemblies you reference to decide if they have changed, and thus it needs to load them again. If Assembly A references Assembly B and B changes, then A needs to be rebuilt because it may be using code in B which has changed. To check the "changedness" of B, it looks at it's references as well - so it B references A, then you have a loop and neither can be successfully compiled because compiling A means B needs to be recompiled, which means A needs to be recompiled. VS doesn't like that! :laugh:

If you have three assemblies: the PresentationLayer, the BusinessLayer, and the DataAccessLayer, then clearly the PL needs to access the BL, and possibly the DAL - but the BL should never try to access the PL, and neither should the DAL.

If there is a case where two assemblies need to access code in the other, then the best thing to do is separate out that common code into one or more discrete assemblies that need no external references, and have both the original assemblies reference that instead.


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

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