Visual Studio的参考和版本 - 它是如何工作的?它是、版本、工作、Visual

2023-09-03 09:39:16 作者:人心会说谎

我们有几种常见的库。理想情况下,我们希望它们都使用DLL的最新版本,即使他们已经被编译的一个旧版本不同(假设目前最新版本是向后兼容)

We have several common libs. Ideally we want them all to use the latest version of a dll even if they have been compiled against an older different version (assume the latest version is backward compatible)

例如,我们有: 项目DLL 通用控件dll的 登录DLL 数据库访问DLL

e.g we have: Project dll Common controls dll Logging dll Database access dll

项目,共同控制参考数据库中的DLL V2。然而,记录引用V1。

Project and common controls reference v2 of database dll. Logging however references v1.

如果不同的版本在不同的组件引用怎样VS挑选使用哪一个? 难道我们必须重新编译V1 DLL使用最新的数据库(V2),或者我们能得到这个自动拾取? 是否有可能迫使一个特定版本中使用?

If different versions are referenced in different components how does VS pick which one to use? Do we have to recompile v1 dll to use the latest database (v2) or can we get this to pick up automatically? Is it possible to force a particular version to be used?

谢谢

亚历

推荐答案

在默认情况下,版本控制的DLL我相信VS将迫使完全匹配。如果你在引用的属性,但是,你会发现一个名为特定版本属性。其设置为假,它会匹配更高版本。

By default, for versioned DLLs I believe VS will force an exact match. If you look in the properties of the reference, however, you'll find a property called "Specific Version". Set that to "false" and it will match later versions.

我没有完整版VS带我找一个合适的MSDN链接,很遗憾。

I don't have the full version of VS with me to find an appropriate MSDN link, unfortunately.

此外,您可以使用 assemblyBinding 元素的应用程序。配置。

In addition, you can use the assemblyBinding element in app.config.