.NET程序集的依赖 [英] .NET Assembly Dependencies

查看:98
本文介绍了.NET程序集的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我缺少明显的东西在这里,但...

Perhaps I am missing something obvious here but...

我建立了一个可重复使用的通用的C#类库项目说(A.DLL),它引用了其他3个总成说(B.DLL,C.dll和D.dll)

I have built a reusable generic C# class library project say (A.dll) which references 3 other assemblies say (B.dll, C.dll and D.dll)

但是,如果我想重用我的组件A.DLL在另一个项目中,我还是要包括引用B.DLL,C.dll和D.dll。

However if I want to reuse my component A.dll in another project I still have to include the references to B.dll, C.dll and D.dll.

有没有什么方法可以配置A.DLL打造其所有的依赖到A.DLL所以我没有包括其他3个总成?

Is there any way you can configure A.dll to build all its dependencies into the A.dll so I don't have to include the other 3 assemblies?

干杯

推荐答案

这是可能的合并组件,使用工具<一href="http://www.microsoft.com/downloads/details.aspx?familyid=22914587-b4ad-4eae-87cf-b14ae6a939b0&displaylang=en"相对=nofollow> ILMerge :

It's possible to merge assemblies, using the tool ILMerge:

C:\Program Files\Microsoft\ILMerge\ILMerge.exe /target:library /out:abcd.dll a.dll b.dll c.dll d.dll"

这将合并的dll A B C D abcd.dll 。它也将合并调试符号而不是XML文档。

This will merge the dlls a, b, c and d into abcd.dll. It will also merge the debugging symbols but not the XML documentation.

另外,你必须引用DLL本身在新的项目,而不是各自的项目。如果合并库成可执行的例外是,你可以在这种情况下,引用的各个库/项目,因为它们将被装入可执行文件。

Also you'll have to reference the dll itself in new projects and not the respective projects. An exception to this is if you merge libraries into an executable, in that case you can reference the respective libraries/projects because they will be loaded with the executable.

Mono项目也有这样的工具,叫做mkbundle。

The Mono Project also has a tool for this, called mkbundle.

此外,还提供 ILRepack 的,其目的是与ILMerge兼容,但FLOSS。

Also available is ILRepack, which aims to be compatible with ILMerge, but is FLOSS.

这篇关于.NET程序集的依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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