加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

有没有办法在dll中打包多个.NET程序集?

发布时间:2020-12-14 04:33:38 所属栏目:Windows 来源:网络整理
导读:我想保持我的组件/组件与源代码的观点明确分开但我在某些情况下(可能与扩展无关)也需要将它们打包在同一个dll中. 是否可以在一个DLL中打包一些.NET程序集?如果是这样,怎么样? 如果可能,你认为这是一个好主意吗?为什么? 任何帮助赞赏! 看看这篇文章: Me
我想保持我的组件/组件与源代码的观点明确分开但我在某些情况下(可能与扩展无关)也需要将它们打包在同一个dll中.

是否可以在一个DLL中打包一些.NET程序集?如果是这样,怎么样?

如果可能,你认为这是一个好主意吗?为什么?

任何帮助赞赏!

看看这篇文章: Merging .NET assemblies using ILMerge

As you know,traditional linking of
object code is no longer necessary in
.NET. A .NET program will usually
consist of multiple parts. A typical
.NET application consists of an
executable assembly,a few assemblies
in the program directory,and a few
assemblies in the global assembly
cache. When the program is run,the
runtime combines all these parts to a
program. Linking at compile time is no
longer necessary.

But sometimes,it is nevertheless
useful to combine all parts a program
needs to execute into a single
assembly. For example,you might want
to simplify the deployment of your
application by combining the program,
all required libraries,and all
resources,into a single .exe file.

csc /target:library /out:ClassLibrary1.dll ClassLibrary1.cs
vbc /target:library /out:ClassLibrary2.dll ClassLibrary2.vb
vbc /target:winexe /out:Program.exe 
    /reference:ClassLibrary1.dll,ClassLibrary2.dll Program.vb

.

ilmerge /target:winexe /out:SelfContainedProgram.exe 
        Program.exe ClassLibrary1.dll ClassLibrary2.dll

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读