.NET 程序集依赖项

发布于 2024-08-22 03:16:01 字数 245 浏览 3 评论 0原文

也许我在这里遗漏了一些明显的东西,但是...

我已经构建了一个可重用的通用 C# 类库项目(A.dll),它引用了 3 个其他程序集(B.dll、C.dll 和 D.dll)

但是如果我想要要在另一个项目中重用我的组件 A.dll,我仍然必须包含对 B.dll、C.dll 和 D.dll 的引用。

有什么方法可以配置 A.dll 将其所有依赖项构建到 A.dll 中,这样我就不必包含其他 3 个程序集?

干杯

Perhaps I am missing something obvious here but...

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)

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.

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?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡紫姑娘! 2024-08-29 03:16:01

可以使用工具 ILMerge

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

这会将 dll abcd 合并到abcd.dll。它还会合并调试符号,但不会合并 XML 文档。

此外,您还必须在新项目中引用 dll 本身,而不是相应的项目。一个例外是,如果您将库合并到可执行文件中,在这种情况下,您可以引用相应的库/项目,因为它们将与可执行文件一起加载。

Mono 项目也有一个用于此目的的工具,称为 mkbundle。

还可以使用 ILRepack,它旨在与 ILMerge 兼容,但属于 FLOSS。

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"

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.

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.

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

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

尾戒 2024-08-29 03:16:01

这就像 DLL 的静态链接一样,可以与本机 C++ 配合良好。据我所知,您无法在 .NET 代码中静态链接程序集,因此您必须包含所有 DLL。

This would be something like static linking of DLLs which works fine with native C++. As far as I know you cannot statically link assemblies in .NET code, thus you have to include all DLLs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文