第三方参考? [英] 3rd Party References?

查看:122
本文介绍了第三方参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个Visual Studio解决方案。一个解决方案/项目(Project1)定义了一个接口(例如IChokable)。第二个解决方案/项目(Project2)包含一个类,它创建一个实现IChokable的对象(fooChicken)。所以Project2必须引用Project1,我明白了。



在第三个解决方案/项目(Project3)中,我创建了一个fooChicken对象。所以Project3必须包含对Project2的引用,我明白了。



但是 - 这不会编译。它抱怨Project3必须还包含对Project1的引用,即使Project3从未尝试访问fooChicken对象上的任何IChokable元素。



我只是在做这个错了?我是否真的必须在每个项目中都引用每个项目引用的每个项目?这让我觉得不对劲。并不是真的可行。如果Project3中的应用程序已经存在于世界中,并且我更新了Project2中的对象以包含新引用并将它们发送出去,该怎么办?那些Project3对象是否会停止运行?



我肯定在这里遗漏了一些东西。这只是Visual Studio的调试首选项吗?

解决方案

您必须添加项目2的依赖项(即项目1)才能使用它。由于项目2具有fooChicken的定义,但它使用项目1中定义的/ implements接口(IChokable),因此需要将其添加到项目3.



没有错在这里,它很简单,我们经常遇到它,使用任何DLL我们必须添加它的所有依赖项。



当你创建一个DLL ...它是非常重要的是,您确切地确定应用程序所需的依赖项及其版本。您必须提供DLL的元数据或读取文件中的依赖关系的详细信息(说明/如何使用)。



对于现实生活中的例子,请看看在下面的链接(以及更多深入到Microsoft企业库的代码库)。

http://msdn.microsoft.com/en-us/library/ ff647601.aspx [ ^ ]



希望这会有所帮助。感谢。

I have three Visual Studio solutions. One solution/project (Project1) defines an interface (IChokable, say). The second solution/project (Project2) contains a a class which creates an object (fooChicken) which implements IChokable. So Project2 has to have a reference to Project1, I get that.

In a third solution/project (Project3), I create a fooChicken object. So Project3 must contain a reference to Project2, I get that.

HOWEVER - this won't compile. It complains that Project3 must ALSO contain a reference to Project1, even though Project3 never tries to access any of the elements of IChokable on the fooChicken object.

Am I just doing this wrong? Do I really have to have a reference in every project to every project referenced by every other project? This strikes me as wrong. And not really doable. What if the app from Project3 existed in the world already, and I updated the objects from Project2 to contain new references, and shipped them? Would those Project3 objects stop functioning?

Surely I am missing something here. Is this just a debugging preference by Visual Studio?

解决方案

You must have to add the dependencies of Project 2 (that mean Project 1) in order to work with it. Since project 2 has definition of fooChicken but it uses/implements interface (IChokable) defined in project 1 so you need to add it to Project 3.

There is nothing wrong here, it is simple and we encounter it very often, to use any DLL we must add all of its dependencies.

When you create a DLL...it is extremely important that you identify exactly what dependencies your application requires, and their versions. You must provide details of the dependencies in metadata of DLL or in read me file (instructions/ how to use).

For a real life example, please have a look at below link (and for more dig into the codebase of Microsoft Enterprise Library).
http://msdn.microsoft.com/en-us/library/ff647601.aspx[^]

Hope this will help. Thanks.


这篇关于第三方参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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