.net 参考特定版本是对还是错? [英] .net reference specificversion true or false?

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

问题描述

我们是在同一个应用程序中从事同一个项目的两家公司.我们每周交换我们的程序集(而不是代码)并引用彼此的 dll.

We are two companies who are working on the same project, in the same application. On a weekly basis we exchange only our assemblies (not the code) and reference each other's dll.

在添加对我们项目的引用时,关于 specificversion 的最佳实践是什么.具体来说,我们什么时候应该使用 truespecificversion 值,在什么情况下我们应该使用 false.

What is the best practice regarding the specificversion when adding reference to our project. Specifically, when should we use a specificversion value of true and in what case should we use false.

推荐答案

此答案将基于您正在对 dll 进行版本控制的假设.

This answer is going to be based on the assumption that you are versioning your dlls.

如果您将 SpecificVersion 设置为 true(这是添加引用时的默认值),则项目将引用具有特定版本(例如 1.0.0.0)的 dll.如果稍后给您一个新的 dll(比如 1.0.1.0),那么您将不得不删除旧的 dll 引用并添加新的引用.这是因为当您有新版本 1.0.1.0 时,该项目专门寻找 1.0.0.0.

If you set SpecificVersion to true (which is the default when adding a reference), then the project will reference to that dll with a particular version (say for instance 1.0.0.0). If, at a later time, you're given a new dll (say 1.0.1.0), then you will have to remove the old dll reference and add the new reference. This is because the project is specifically looking for 1.0.0.0 when you have a new version 1.0.1.0.

另一种方法是将 SpecificVersion 设置为 false,这会告诉项目找到最新的可用 dll 并使用该 dll.这样做的问题是项目现在需要在不同位置寻找"您引用的 dll,这会增加您的构建时间.即使它知道您引用的 dll 的路径,它也会这样做.我不确定这是一个错误还是设计使然.它可能会检查除了您引用的 dll 之外是否还有更新的 dll(可能在 GAC 或其他地方).

The alternative to this is to set the SpecificVersion to false, which tells the project to find the latest available dll and use that one. The problem with this is that the project is now required to "hunt" in various places for the dll you've referenced, which can increase your build time. It will do this even though it knows the path of the dll you've referenced. I'm not sure if this is a bug or if this is done by design. It might be checking to see if there are any newer dlls besides the one you've referenced (perhaps in the GAC or elsewhere).

这是一篇文章更详细地描述了这个问题.

Here's an article that describes this issue in more detail.

这篇关于.net 参考特定版本是对还是错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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