解析/使用多个程序集版本从第三方的依赖 [英] Resolving/using multiple assembly versions from 3rd party dependencies

查看:268
本文介绍了解析/使用多个程序集版本从第三方的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我与它的依赖性层次的问题。我在code使用图书馆( WriteableBitmapExtensions ),我有另一个第三方库它也使用WriteableBitmapExtensions。只有其他图书馆强烈依赖于特定的旧版本,而我的code需要在其最新版本的功能。

In my project, I have a problem with its dependency hierarchy. I use a library (WriteableBitmapExtensions) in my code, and I have another 3rd party library which also uses WriteableBitmapExtensions. Only the other library is strongly tied to a specific, older version, and my code needs the functionality in its latest version.

下面的依赖关系的描述:

Here's a depiction of the dependencies:

有类似的问题和放大器;解决方案,但它们在运行时通过一个配置文件集绑定解决这个问题,但我不认为这是一个Silverlight应用程序兼容。

There are similar questions & solutions but they resolve it with assembly binding at runtime via a config file, but I don't think this is compatible for a Silverlight application.

<一个href="http://stackoverflow.com/questions/3158928/referencing-2-differents-versions-of-log4net-in-the-same-solution">Referencing log4net的在同一溶液的2型动物版本

<一个href="http://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder">Using同样装配在同一文件夹不同版本

<一个href="http://stackoverflow.com/questions/4381195/3rd-party-libraries-refer-to-different-versions-of-log4net-dll">3rd第三方库是指不同的版本log4net.dll

<一个href="http://stackoverflow.com/questions/225810/how-to-deal-with-multiple-versions-of-dependencies">How对付多个版本的依赖?

那么,有没有办法解决这些不同版本的组件依赖于Silverlight的背景下?如果没有,我想我的选择是:

So is there a way to resolve these different versions of assembly dependencies in a Silverlight context? If there isn't, I figure my options are:

1)最有可能的,我可以说服第三方库的供应商来更新使用WriteableBitmapExtensions的最新版本,但我preFER不依赖于他们来说,跟上最新的。尤其是自WriteableBitmapExtensions项目仍然在更新,我们经常利用自己的新功能。

1) Most likely I can convince the vendor of the 3rd party library to update to use the latest version of WriteableBitmapExtensions, but I'd prefer to not be dependent on them keeping it up-to-date. Especially since the WriteableBitmapExtensions project is still being updated and we're often taking advantage of their new features.

2)由于WriteableBitmapExtensions是开源的,我想我可以重新编译源作为一个新的组件MyWriteableBitmapExtensions和使用,在我的源代码code。但我会遇到这个问题再次如果两个第三方类库引用不同版本WriteableBitmapExtensions的。

2) Since WriteableBitmapExtensions is open-source, I suppose I can recompile its source as a new assembly "MyWriteableBitmapExtensions" and use that in my source code. But I'll run into this issue again if two 3rd party libraries reference different versions of WriteableBitmapExtensions.

我怀疑我会去与选项2,但我想知道是否有这样做的更好的方法(如运行时组件中的其他问题结合)之前,我提交/重构。谢谢!

I suspect I'll be going with option 2, but I'd like to know if there's a better way of doing this (like the runtime assembly binding in the other questions) before I commit/refactor. Thanks!

推荐答案

正如我所说的在我的评论方案1应随时可用,因为V1实际上是一个pre测试版。

As I've said in my comment Option 1 should be readily available because "v1" is actually a "pre beta" version.

如果没有在第三方供应商使用非beta版本发布一个版本的延迟,你的方案2是你的下一个选择。只要确保你使用一个完全新的身份为你的 MyWriteableBitmapExtensions 的版本:专门使用一个不同的AssemblyName,文件名,强名称签名和用于身份任何的GUID,包括COM。

If there is a delay in the 3rd party vendor releasing a build using a non-beta version, your Option 2 is your next option. Just make sure you use a completely new identity for your build of MyWriteableBitmapExtensions: specifically use a different AssemblyName, FileName, Strong Name Signature and any GUIDs used for identity, including for COM.

如果你并不需要新的功能或者V2是向后兼容的V1,组装结合仍是preferable选项 - 我还没有证实这是否可以使用Silverlight,但我会感到惊讶,如果它不是虽然我现在也认为真正的组装暴食是在Silverlight可能不可用,因为整个System.Configuration命名空间是缺少Silverlight的(除了两个枚举的 System.Configuration.Assemblies )。

If you didn't need the new functionality or if the v2 was backward compatible with v1, assembly binding would still be the preferable option -- I haven't confirmed if this is available with Silverlight, but I'd be surprised if it wasn't though I now agree true assembly binging is probably unavailable in Silverlight because the whole System.Configuration namespace is missing from Silverlight (except for two enumerations in System.Configuration.Assemblies).

然而,另一种选择是调整的最新源$ C ​​$ C,以便它的确实的生产的东西是向后兼容V1,或许打破了v2的功能,如果你有 - 在这样的一种方式V2功能仍然可以使用,只是一个重新编译,现在的的原身份(的AssemblyName,文件名,强名称签名等)。然后,你应该能够使用一个程序集这两种方案了。

Nevertheless, another option is to adjust the latest source code so that it does produce something that is backward compatible to v1, perhaps breaking the v2 features if you have to -- in such a way the v2 features can still be used, just with a recompile, now with the original identity (AssemblyName, FileName, Strong Name Signature, etc.). Then you should be able to use the one assembly for both scenarios again.

这篇关于解析/使用多个程序集版本从第三方的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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