• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > 编程与数据库 > net编程 >

嵌入Dll到.net程序中的方法(2)

来源: www.dedecms8.com 编辑:织梦吧 时间:2012-06-27点击:

ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.

Note that anything that depended upon any of the names of the input assemblies, e.g., configuration files, must be updated to refer instead to the name of the target assembly.

Any Win32 Resources in the primary assembly are copied over into the target assembly.

There are many options that control the behavior of ILMerge. These are described in the next section.

Ilmerge 相关的命令行参数是:

ilmerge [/lib:directory]* [/log[:filename]] [/keyfile:filename [/delaysign]] [/internalize[:filename]] [/t[arget]:(library|exe|winexe)] [/closed] [/ndebug] [/ver:version] [/copyattrs [/allowMultiple]] [/xmldocs] [/attr:filename] ([/targetplatform:<version>[,<platformdir>]]|v1|v1.1|v2|v4) [/useFullPublicKeyForReferences] [/zeroPeKind] [/wildcards] [/allowDup[:typename]]* [/allowDuplicateResources] [/union] [/align:n] /out:filename <primary assembly> [<other assemblies>...]

其中目标exe或者程序集,要放在输入的程序集里面的第一位置,其他dll放在它之后.其中/out:参数是必须的,其他参数可以参考文档

如图1 示例,命令行参数是

ilmerge EmbeddedDLL2ExeDemo.exe ThirdPartyDllDemo.dll /ndebug /out:EmbeddedDll2Ex 
eDemo.exe

这样既可,该方法比方法1更完美,不过这个Ilmerge 在使用的时候还有一些不足的地方,比如/ver:version,这个参数设置后没有效果;

ilmerge就用自己把它引用到的两个dll嵌软到它自身里面了.

方法3:使用.Net混淆器都附带这样的功能,可以把多个dll整合到一个可执行文件中。

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ