如何使用Assambly有两个不同的版本 [英] How Can Use Assambly having two diffrent versions

查看:113
本文介绍了如何使用Assambly有两个不同的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有两个不同版本的程序集,我想在我们的系统中使用两个程序集,不同条件如旧版本新版本,如何维护

请给我解决方案。



谢谢

I have a Assembly with two different versions , i want to use both assembly in our system with different conditions like old version new version, how can maintain
please give me solution.

Thanks

推荐答案

添加每个引用并更改其默认别名。如果在引用节点下找到程序集并查看其属性,您将看到它具有别名global。将其更改为新装配的newDll和旧装配的oldDll。您现在可以通过以下方式明确引用每个程序集;



Add each reference and change their default alias. If you find the assembly under the references node and view its properties you'll see it has an alias of "global". Change that to "newDll" for your new assembly and "oldDll" for your old one. You can now explicitly refer to each assembly via;

oldDll::MyNameSpace.MyClass
newDll::MyNameSpace.MyClass





或者在页面顶部的使用列表中使用别名





Or use aliasing in the using list at the top of the page

using OldProduct = oldDll::MyNameSpace.Product;
using NewProduct = newDll::MyNameSpace.Product;





然后在你的代码中





then in your code

OldProduct p = new OldProduct





如果你想让我们的代码使用然后,程序集的不同版本会相应地更新web.config \ app.config文件。



If you want to simply have our code use different versions of the assembly then update the web.config\app.config file appropriately.


首先,我建议一定要避免这种情况。将所有旧版本合并为一个,清理整个产品,不要用人为的复杂遗产折磨自己。



用于解决组装冲突时的存在两个或更多不同的版本,请参阅,例如:

http://stackoverflow.com/questions/223195/referencing-different-versions-of-the-same-assembly [ ^ ],

同一个文件夹中的相同程序集 [ ^ ]。







请请参阅下面评论中的讨论。 Kornfeld Eliyahu Peter提醒我关于 extern别名的功能。我需要在下面的评论中提供一些解释。



-SA
First of all, I would advise to avoid this situation by all means. Merge all old versions in one, clean up the whole product, don't torture yourself with artificially complicated legacy.

For the resolution of the assembly conflict in the presence of two or more different versions, please see, for example:
http://stackoverflow.com/questions/223195/referencing-different-versions-of-the-same-assembly[^],
http://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder[^].



Please see the discussion in comments below. Kornfeld Eliyahu Peter reminded me about the extern alias feature. It needs some explanation I tried to provide in my comment below.

—SA


这篇关于如何使用Assambly有两个不同的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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