如何处理多个版本的依赖?多个、如何处理、版本

2023-09-03 01:18:29 作者:姐的霸気√伱囨嬞

您好我有一个依赖层次,我不能确定如何解决一个问题:

Hi I have a problem with a dependency hierarchy I am unsure how to solve:

https://m.xsw88.com/allimgs/daicuo/20230903/538.png

问题是我应该如何参考这些依赖关系MyProject的项目。我已经建立BaseProject和CommonUtil(1.0版),它建有成组件。现在,在MyProject的,我使用的类CommonUtil,我不确定我是否应该引用CommonUtil.v.1.0或者如果我可以/应该参考CommonUtil的当前版本(2.0版)。

The problem is with how I should reference these dependencies from MyProject project. I have built BaseProject and the CommonUtil(version 1.0) it was built with into assemblies. Now in MyProject I am using classes from CommonUtil and I am unsure if I should reference the CommonUtil.v.1.0 or if I could/should reference the current version of CommonUtil (v 2.0).

这CommonUtils装配应我从MyProject的参考? 我不能引用这两个组件作为VS告诉我它无法确定使用哪个程序集,因为它们都包含一些相同的方法。如果我只引用V.1.0我也许不会有我需要的一切,从2.0版,如果我只引用2.0版我也许不会有V.1.0所有功能(这BaseProject)的需求。

Which CommonUtils assembly should I reference from my MyProject? I cannot reference both assemblies as VS tells me it cannot determine which assembly to use as they both contain some of the same methods. If I only reference v.1.0 I would perhaps not have everything I need from v.2.0 and If I only reference v.2.0 I would perhaps not have all capabilities in v.1.0 (which BaseProject) needs.

推荐答案

如果您使用的是BaseProject直接返回在MyProject的类,你需要坚持使用同一版本(1.0)。但是,如果BaseProject只在内部使用这些类,不与MyProject的分享,你可以放心地使用新版本(2.0)。

If you are using the classes that BaseProject returns directly within MyProject, you need to stick with the same version (1.0). But if BaseProject only uses those classes internally and does not share with MyProject, you can safely use the new version (2.0).

最佳实践:强烈命名您的组件,以便编译器可以帮你

Best practice: strongly name your assemblies so that the compiler can help you out.