合并的最佳实践集? [英] Best practices for merging assemblies?

查看:182
本文介绍了合并的最佳实践集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道创建库的版本中,当被包含在其他项目中涉及的依赖关系,如果我应该包括与否有什么启发。

I am wondering what are the heuristics when creating releases of libraries to be included in other projects in relation to dependencies and if I should include them or not.

我的问题是这样的:

我有一个CommonUtilities库,提供顾名思义一组实用工具,可以在一个以上的地方使用。 CommonUtilities的依赖性​​包括log4net.dll(日志框架)和Oracle.DataAccess.dll(数据库驱动程序)。

I have a CommonUtilities library that provides as the name implies a set of utilities that can be used in more than one place. Dependencies of CommonUtilities include log4net.dll (the logging framework) and Oracle.DataAccess.dll (database driver).

我有一个名为MyProject的另一个项目,我想包括在CommonUtilities。MyProject的还取决于Oracle.DataAccess。

I have another project called MyProject that I want to include CommonUtilities in. MyProject also depends on Oracle.DataAccess.

如果我使用ILMerge和合并CommonUtilities成一个单一的组件CommonUtilities.dll和参考,从MyProject的一切编译,但我相信我应该明确地引用Oracle.DataAccess从MyProject的,因为它是一个依赖,而不是用汇编合并成CU 。添加引用Oracle.DataAccess以及结果不明确的使用说明中,因为有两处引用Oracle.DataAccess组件。

If I use ILMerge and merge CommonUtilities into a single assembly CommonUtilities.dll and reference that from MyProject everything compiles but I am sure I should explicitly reference Oracle.DataAccess from MyProject as it is a dependency and not use the assembly merged into CU. Adding a reference to Oracle.DataAccess as well results in ambiguous using statements as there are two Oracle.DataAccess assemblies referenced.

在我的情况会导致编译错误使用ILMerge /内在从内在Oracle.DataAccess组件类型正在从CommonUtilities返回,因为它们标记内部MyProject的不承认返回的类型。

Using ILMerge /Internalize in my case results in compile errors as types from the internalized Oracle.DataAccess assembly are being returned from CommonUtilities and as they are marked internal MyProject does not recognize the type returned.

,使这项工作的唯一方法就是这个特定的组件(Oracle.DataAccess)不合并成CommonUtilities,只引用从MyProject的。 这反过来又创造了一个新的问题:哪些Oracle.DataAccess.dll我应该参考 - 依赖随CommonUtils与否

The only way to make this work is simply to not merge this particular assembly (Oracle.DataAccess) into CommonUtilities and only reference that from MyProject. This in turn creates a new problem: Which Oracle.DataAccess.dll should I reference - the dependency distributed with CommonUtils or not?

还有没有其他的办法去了解这一切?

Are there other ways to go about all this?

推荐答案

短,易版本:

在一个进程中的每个引用给定的大会应当参照相同的版本。

如果你不这样做,你可能会陷入深深的烦恼,因为该应用程序的一部分不能与另一由于版本不匹配。

If you don't, you might get into deep troubles because one part of the app cannot talk to another due to version mismatch.

即使有真正的私有的东西,如log4net的,你可能会错过共享配置空间的可能性,就像使用一个共同的根记录器的应用程序的所有部分。当然,在这种情况下,最后的呼叫​​是 - 一如既往 - 与负责的显影剂

Even with "really private" stuff like log4net you might miss out on possibilities for shared configuration space, like using a common root logger for all parts of the app. Of course, the final call in this case is -- as always -- with the responsible developer.

另请参阅有关 ILMerge和第三方组件这等问题。

See also this other question about ILMerge and 3rd party assemblies.

这篇关于合并的最佳实践集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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